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.

Also, unlike subroutines, program execution can't accidentally "fall into" a procedureor function. As far as the execution path of a program is concerned, functionand procedure definitions are invisible. For example, when this four-line programis executed:CALL PrintSomethingSUB PrintSomethingPRINT "Printed from within PrintSomething"END SUBthe message appears only once.Note: You must treat your procedure and function definitions as isolated islandsof code. Don·t jump into or out of them with GOTO, GOSUB, or RETURN statements- you may get unpredictable and/or disastrous results.Note that neither procedure nor function definitions may be nested; that is, youcannot define another procedure or function within a procedure or function definition(although a procedure or function can contain calls to other procedures andfunctions).Argument CheckingUnlike some other BASIC compilers, <strong>Turbo</strong> <strong>Basic</strong> checks to make sure that thenumber and type of arguments in a program's procedure and function calls agreeswith the number and type of formal parameters in the corresponding definitions.For instance, attempting to compile the programDEF FNDummy(a,b)END DEFt = FNDummy(3)results in a Parameter Mismatch error in line 3, because FNDummy requires twoarguments.Advanced Topics in Functions and ProceduresPassing Parameters by Value or ReferenceThere are some subtle but important differences between functions and procedures,and understanding these differences requires understanding how <strong>Turbo</strong><strong>Basic</strong> processes procedure and function calls at runtime (see Table 4-4).88 <strong>Turbo</strong> <strong>Basic</strong> Owner's Handbook

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

Saved successfully!

Ooh no, something went wrong!