Advent Instruments Inc.
4. Programming
While functions are called inside expressions as:
<identifier> [ ( <param1> [ , <param2> ] ) ]
It is important to note some restrictions with functions and parameters.
•
When calling a function or subroutine, expressions cannot be used inside a
parameter list. Only variables and constants can be passed.
•
All parameters are “read only” from inside a function or subroutine. The called
routine cannot modify any of the parameter values, as they are treated as
constants within the routine.
•
Variable storage within routines does not support recursion. If a function or
subroutine is called with recursion, its variable contents are identical to that of
the calling instance, and changing its value changes it for all of the other
instances
•
The GOSUB and RETURN statements are not allowed inside a function or
subroutine. These statements are only allowed inside a PROCESS block.
To return a value from a function supply an expression following the WITH keyword,
which occurs after EXIT FUNCTION or END FUNCTION. The expression is computed
and its results returned when the function ends. The WITH keyword is optional and if
missing the function will return either zero or an empty string, depending on the
function's data type.
An END SUB or END FUNCTION statement must be included to mark the end of the
routine. Once the program reaches this point control is passed back to the calling section.
To exit prematurely from a routine, use the EXIT SUB or EXIT FUNCTION statement.
Variables & Constants
The scripting language supports the use of variables for holding and processing data. The
type of data stored by the variable and its scope is determined by how and where it is
declared. Every variable in a script program is declared by using one of the data type
keywords:
NUMERIC, or STRING
As implied, numeric variables hold a single floating point numeric value while string
variables contain ASCII characters. The syntax for declaring a variable is as follows:
[<modifiers>] NUMERIC|STRING [(<register>)] <identifier> [ =
<expression>
]
•
<modifiers>
Optionally, one or more of the following keywords may be
used to define the scope and usage of the variable:
LOCAL, GLOBAL, EXPORT, IMPORT
•
<register>
An integer value used to force the compiler to use the
specified register number as the storage location for the variable. This field is
AI-7280 Programmers Guide - Direct Control
87