Chapter 6 RAPID!
Commands
WCDMA Options Version 6.20
169
GLOBAL
SUB – EXIT SUB – END SUB –
CALL
Example
The following example calculates the faculty (n! :=
1*2*3*...*n) of a given integer number n. In order to do so,
the function calls itself recursively:
FUNCTION Faculty(n)
IF n<2 THEN
Faculty = 1
EXIT FUNCTION
END IF
Faculty = n * Faculty(n-1)
END FUNCTION
Syntax
GLOBAL varName [ {, varName} ]
Parameters
varName is a valid variable name.
Description
Declares a global variable. Global variables are accessible
in the main program, in all programs included by CHAIN
and in all related procedures and functions.
Any global variable is valid and accessible from the pro-
gram line, in which it has been declared.
Note: If a local variable has been declared or used before,
that carries the same name as the global variable, then
the global variable is not accessible.
Example
GLOBAL strg$, counter declares a global string
and a global numeric variable.
Syntax
SUB subName ( [ parameter [{, parame-
ter } ]] )
[ instructions ]
[ EXIT SUB ]
END SUB
...
[CALL] subName ([ parameter [{,
parameter } ]] )
Parameters
subName is a valid name for the procedure (subroutine)
(same syntax rules apply as for variable names),
parameter may be any valid numeric or string expres-
sion,
instructions are an (optional) number of program
lines.