4. Programming
Advent Instruments Inc.
Each process runs completely independently from each other. However, if needed, a
common data pool is available to be shared between the processes for inter-process
communications.
If a program contains only one process block it is executed when the program is started.
When a program contains multiple process blocks then only the process marked as the
startup process by the compiler is started. The other process blocks must be started from
within the program. The startup process of a program is specified as part of the project
settings.
The syntax for a process block is as follows:
PROCESS <identifier>
<statements>
[EXIT
PROCESS]
END PROCESS
The <identifier> is a unique name that consists of only letters and numbers.
When a program reaches the END PROCESS or EXIT PROCESS command, that process
is terminated. Process blocks cannot be nested.
Function & Subroutine Blocks
In addition to processes, functions and subroutines can be defined and called from within
a program. Both the subroutines and functions may pass arguments for processing.
Subroutines do not return any data, while functions return either a numeric or string data
type. Subroutines are initiated by the CALL command while functions may be part of an
expression. The syntax for the function and subroutine blocks are as follows.
FUNCTION <type> <identifier> [(<type> <identifier> ...[,<type>
<identifier>])]
<statements>
[EXIT FUNCTION [ WITH <expression> ]
END FUNCTION [ WITH <expression> ]
SUB <identifier> [(<type> <identifier> ...[,<type> <identifier>])]
<statements>
[EXIT
SUB]
END SUB
All user defined functions or subroutines must be declared outside of a PROCESS block,
and cannot be nested (defined inside another). The identifier chosen for a routine is
global in scope and may not be used as constants or variables anywhere else in the
project.
If parameters are passed to the functions and subroutines, a parameter list enclosed in ( )
brackets must be specified. The parameter list indicates the data type for each parameter,
along with a unique identifier for the parameter. When calling functions or subroutines,
the calling statement’s parameter list is compared to the parameter list in the FUNCTION
or SUB statement. If the number of parameters is different or the data types do not match
an error is reported.
The syntax for calling a subroutine is:
CALL <identifier> [ ( <param1> [ , <param2> ] ) ]
86
AI-7280 Programmers Guide - Direct Control