HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)

3- 38
| change actual | parameter. | |
| parameter |||
|| | |
---------------------------------------------------------------------------------------------
|| | |
| Variables Passed | File designators*. | All not mentioned to the left. |
| This Way |||
| | Arrays. | Scalar variables enclosed in |
| | | parentheses. |
| | Array elements. | |
| | | String literals. |
| | Scalar numeric variables. | |
| | | Numeric literals. |
| | Unsubscripted scalar string | |
| | variables. | Expressions |
|| | |
| | | Substrings |
|| | |
---------------------------------------------------------------------------------------------
|| | |
| Corresponding | Exactly the same type and both | Compatible types.** |
| parameters must | scalar or both array. | |
| be |||
|| | |
---------------------------------------------------------------------------------------------
Table 3-29 Notes
* An actual parameter that corresponds to a formal file designator
parameter must have a value that can be converted to a short integer
in the range [1, 32767].
** An actual and formal parameter are compatible if the parameters are
both string or both numeric (they must also be scalar, because whole
arrays cannot be passed by value). If the parameters are of
different numeric types, HP Business BASIC/XL converts the value of
the actual parameter to the numeric type of the formal parameter
before assigning it to the formal parameter.
Example
10 A,B=0
20 CALL Sub(A,(B)) !A is passed by reference
25 REM !B is passed by value
30 PRINT A !Prints 1 (Sub changed A)
40 PRINT B !Prints 0 (Sub did not change B)
99 END
100 SUB Sub (X,Y) !A corresponds to X; B corresponds to Y
110 X=X+1
120 Y=Y+2
130 PRINT X !Prints 1
140 PRINT Y !Prints 2
150 SUBEND
The number of actual parameters in a subprogram call must be the same as
the number of formal parameters in the SUBPROGRAM or DEF FN statement
that defines the beginning of the subprogram or function. The actual
parameters are evaluated and assigned to the corresponding formal
parameters from left to right.
Initial Subprogram Environment
Every program unit has its own operating environment. When HP Business