13.07.2015 Views

Turbo Basic

Turbo Basic

Turbo Basic

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

DEF FN/END DEF statementFunctionSyntaxDEF FN/END DEF define a function.Single line:DEF FNidentifier [(argument list)]Multiline:expressionDEF FNidentifier [(argument list)][LOCAL variable list][STATIC variable list][SHARED variable list]. statements[EXIT DEF][FNidentifier = expression]END DEFRemarksidentifier is the unique name to be associated with the function, andmust follow the naming conventions for labels and variables (that is,a letter followed by any number of letters and/or digits). argumentlist is an optional, comma-delimited sequence of formal parameters.The parameters used in the argument list serve only to define thefunction: They have no relationship to other variables in the programwith the same name.DEF FN and END DEF bracket and name a subroutine-likegroup of statements called a function. A function may be optionallypassed one or more arguments by value. Functions return a value(the type of which is controlled by the function's name, as though itwere a variable) and may therefore be called from any statementthat can accept a value of the appropriate type.Function Definitions and Program FlowThe position of function definitions is immaterial. A function canbe defined in line 1 or line 1,000 of a program without regard forwhere it is used; and you need not direct program How through afunction as an initialization step (as you must do with single-linefunctions in Interpretive BASIC). The compiler sees your definitionswherever they might be.Also, unlike subroutines, execution can't accidentally "fall into" afunction. As far as the execution path of a program is concerned,function and procedure definitions are invisible.<strong>Turbo</strong> <strong>Basic</strong> Reference Directory 177

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!