Value parameters are declared as follows:
_________________________________________________________________________________________________________
Value parameters
___________________________________________________________________
When parameters are declared as value parameters, the procedure gets a copy of the parameters that the calling statement passes. Any modifications to these parameters are purely local to the procedure’s block, and do not propagate back to the calling block.
A block that wishes to call a procedure with value parameters must pass assignment compatible parameters to the procedure. This means that the types should not match exactly, but can be converted to the actual parameter types. This conversion code is inserted by the compiler itself.
Care must be taken when using value parameters: value parameters makes heavy use of the stack, especially when using large parameters. The total size of all parameters in the formal parameter list should be below 32K for portability’s sake (the Intel version limits this to 64K).
Open arrays can be passed as value parameters. See section 14.4.5, page 778 for more information on using open arrays.
For a parameter of a simple type (i. e. not a structured type), a default value can be specified. This can be an untyped constant. If the function call omits the parameter, the default value will be passed on to the function. For dynamic arrays or other types that can be considered as equivalent to a pointer, the only possible default value is Nil.
The following example will print 20 on the screen:
program testp; Const MyConst = 20; Procedure MyRealFunc(I : Integer = MyConst); begin Writeln('Function received : ',I); end; begin MyRealFunc; end.