The following example shows how the Max subroutine procedure accepts three parameters and returns a value. The subroutine returns the maximum number for any given two numbers.
The Max procedure uses the following variables:
dA and dB are parameters that use the Val parameter type. They accept numbers passed by value to the procedure.
dx uses the Var parameter type so that it can store a result which can then be returned to the calling procedure, Max.
The Max procedure compares dA to dB to determine which variable has the greater value, stores the result (dx) as a Var parameter type, and then returns the higher value.
To call the result (dx) stored as a Var parameter type in this procedure, you can use the following example code:
Max(1,10,d) |
|
print d |
!This will print 10. |