Structure of a Proc
A Proc is stored as an item in a dictionary or data file. The first attribute (first line) of a Proc is always the code PQ or PQN. This tells the system to invoke the Proc or NEWProc processor respectively. All subsequent attributes contain Proc statements that generate TCL commands, insert parameters into a buffer, alter the flow of statement execution, and so on.
Proc statements consist of an optional numeric label, a command and optional command arguments.
PQ and PQN Procs
The principal form of Proc used on Reality is known as PQN or 'new' Proc. These have PQN as the first line in the file item they are stored in. They can read and write to files. They can also reference buffer parameters directly. Buffer parameters are separated by attribute marks.
PQ or 'old' Proc is also supported. It is retained for compatibility with systems that can only support PQ. These have PQ as the first line in the item. They cannot read or write to files, and buffer parameters are separated by blanks. Buffer referencing is not supported.
PQN and PQ Procs can run concurrently. However, they are incompatible in terms of linking: you cannot pass control from one type of Proc to another.
See Differences between PQ and PQN Proc for more details.
Linking Procs
Procs of the same type can be linked together to effect larger Procs in much the same way as DataBasic programs are CHAINed. Procs can also call internal and external subroutines.
Labels
Any Proc command can optionally be preceded by a numeric label. This label uniquely identifies the associated Proc command for branching or looping purposes. Labels consist of one or more numeric characters (for example, 5, 999, 72, and so on). The first character of the label must be the first character on the line, and there must be at least one space between the label and the statement.
Multiple Commands
More than one command can be placed on the same line by separating commands with a subvalue mark character (X'FC', entered by typing CTRL+\).
The use of a subvalue mark within a line allows you to use a series of Proc commands on the same line, except for two-line conditional commands and some others.
Commands which should not be followed by another command on the same line are: (), [], B, BO, F, F;, FB, F-CLEAR, F-FREE, F-KLOSE, F-OPEN, F-READ, F-UREAD, F-WRITE, GOSUB, H, IBH, IH, MVA, MVD, O, P, RI, RO, RSUB, RTN, U, X, and lines which are continuation lines for a T or L command on a previous line.
The M (Mark) command may be followed by other commands on the same line, but it must be the first command on a line. Any command following the M command requires separation with a subvalue mark rather than a space, unlike numeric labels.
Examples of multiple command lines are explained in the topic Programming Efficiency.
Comment Commands
Any command starting with 'C' or '*' is treated as a comment and is ignored by the Proc processor. However, if there are multiple commands on the line, only those immediately following a 'C' or '*' are ignored (that is, until a subvalue mark or the end of line is reached).
If the 'C' or '*' is placed after a label, the label remains active.
If you compile a Proc (using PQ-COMPILE), comments become null attributes in the compiled version. Alternatively, they can be stripped out altogether with the S option of PQ-COMPILE.
For more information on comments, refer to the explanation of the C command.