START Statement |
The START statement defines the start of a module definition. Subsequent statements are not executed immediately, but are instead collected for later execution. The FINISH statement signals the end of a module definition.
The arguments to the START statement are as follows:
is the name of a user-defined module.
are names of variable arguments to the module. Arguments can be either input variables or output (returned) variables. Arguments listed in the GLOBAL clause are treated as global variables. Otherwise, the arguments are local.
are statements making up the body of the module.
When no name argument is given in the START statement, the module name MAIN is used by default. If an error occurs during module compilation, the module is not defined. See Chapter 6 for details.
The following example defines a module named MYMOD that has two local variables (A and B) and two global variables (X and Y). The module creates the variable Y from the arguments A, B, and X.
start mymod(a,b) global(x,y); y=a*x+b; finish; x = 1:4; call mymod(2, 1); print y;
y | |||
---|---|---|---|
3 | 5 | 7 | 9 |