When a program contains several script, the execution starts by the last one
which can not accept parameters. The statement CALLSCRIPT
(i.e. or the obsolete COMMAND) is
used to call a script.
Example 6:A 'Hello World' program with two SCRIPT.
SCRIPT my_print(str) PRINT str ENDSCRIPT SCRIPT main () PRINT "Hello " CALLSCRIPT my_print("World") ENDSCRIPT
By default, the argument passing protocol is by value (i.e. the script works on a copy). It is possible to use references by adding the prefix "&" before the variable used as an argument. For instance, the example 7 implements a script that increments its argument (if a reference is used of course).
SCRIPT inc(X) X := X+1 ENDSCRIPT SCRIPT main() a:=1 CALLSCRIPT inc(&a) PRINT a // print 2 b:=1 CALLSCRIPT inc(b) PRINT b // print 1 (b is unchanged) ENDSCRIPT
Remark: Arguments passed by reference are not restricted to the scripts. Some predefined functions or attributes may use them.