Passing information with arguments
CALL subroutine_name argument1, argument2, argument3,…
function(argument1,argument2,argument3,…)
Using the ARG instruction
ARG arg1, arg2, arg3, …
The names of the arguments that are passed do not have to be the same as those on the ARG instruction because information is passed by position rather than by argument name. The first argument sent is the first argument received and so forth. You can also set up a template in the CALL instruction or function call. The language processor then uses this template in the corresponding ARG instruction. For information about parsing with templates, see Parsing data.
perim
by specifying the value in the RETURN instruction. The main program receives the value in the
special variable RESULT .
In the two preceding examples, notice the positional
relationships between
long
and
length
,
and
wide
and
width
. Also notice
how information is received from variable
perim.
Both programs include
perim
on a RETURN instruction.
For the program with a subroutine, the language processor assigns
the value in
perim
to the special variable RESULT.
For the program using a function, the language processor replaces
the function call
perimeter(long,wide)
with the value
in
perim.
Using the ARG built-in function
Another way for a subroutine or function to receive arguments is with the ARG built-in function. This function returns the value of a particular argument. A number represents the argument position.
ARG length, width you can use the ARG function as follows:
length = ARG(1) /* puts the first argument into length */
width = ARG(2) /* puts the second argument into width */
For more information about the ARG function see ARG.