1.2.4.1 The PROC statement

Driver procedures are defined with the PROC statement. The PROC keyword is followed by one of PUT, GET, SUBSCRIBE, SUBROUTINE or ASYNC. Chapter Using subroutines tells more about this type of procedures. ASYNC procedures handle messages sent by the device in an unsolicited way. Chapter ASYNC procedures. Procedures do not have an explicit end keyword, a procedure automatically ends where another definition (procedure, variable or table) starts.

proc-statement.svg

PUT and GET procedures must have a WATCH keyword followed by one or more names of variables this procedure shall be bound to.

Generally, any variable which is referenced in a procedure must be defined before using the VAR statement. Although the driver language allows to define variables between procedures (a VAR statement closes an open procedure definition), the drivers supplied by SatService GmbH first define all variables and then all procedures for this reason.

Examples

There are two complete device drivers listed at the end of this section, showing several flavors of procedure definitions:

Variable subscriptions

The PROC SUBSCRIBE variant of procedure definitions permits to react on changes of parameters controlled by other devices drivers. Such a procedure is called every time the referenced parameter changes. The parameter to listen to may be defined directly with its full parameter name in double quotes (e.g. DEVICE.some.name) or by the name of a variable in this device driver which contains the name of the parameter to listen to.

SUBSCRIBE type procedures are executed in the thread context where the parameter it's listening to is changed, not in the thread context of the local device driver. For this reason, SUBSCRIBE procedures never should contain IO-related statements like PRINT, INPUT, READ, oder WRITE. Communicating to the device from different program threads may break the communication protocol. That is much similar like when two people are talking at the same time, probably you won't understand any of them.