13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

To declare a variable parameter, you write VAR in front of its declarationin the procedure or function definition. Every VAR parameter receives aninitial value from the calling program. But if the procedure or functionchanges that value, the VAR parameter "reaches out" into the callingprogram, changing the value of the variable stored there that supplied itsinitial setting.To declare a value parameter, omit VAR. Value parameters also receivedata from the calling program; but when the routine changes their valuesinternally there is no outside effect.A value parameter may receive data from any kind of expression. Avariable parameter may receive data only from a variable.Other Terminology: Variable parameters are often said to be "passedby reference"; value parameters "passed by value." This refers to the waythe calling program sends their values to the procedure or function. Itpasses the memory address of variable parameters and the actual valueof value parameters. With EXTERNAL procedures and functions, valueparameters of type STRING, RECORD, and ARRAY are also passed byreference, as if they were variable parameters. See Chapter 9 for adiscussion of EXTERNAL routines.Calling Procedures and FunctionsA procedure or function is called by simply writing its identifier in thesource text, followed by its parameter list (if it has one) in parentheses. Theparameters are separated by commas:identifiert------.-,.....-;M expression 1t--...._,,._,...The identifier (or at least the first eight characters thereof) must be thesame as the identifier used in the procedure or function definition.The parameter list in a procedure or function call contains the samenumber of parameters as were listed in the procedure or function definition.Those in the definition are called formal parameters; those in the callingCalling Procedures and Functionslll-131

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

Saved successfully!

Ooh no, something went wrong!