Programming Efficiency
GO vs. GO F and GO B
A GO command searches for the specified statement label starting at the very beginning of the Proc (unless the Proc has been compiled using PQ-COMPILE). GO F and GO B look for a M(ark) command starting from the current execution location. Therefore, it is more efficient to confine the use of statement labels to the beginning of the Proc and use marks for branches deeper into the code. Because GO F and GO B cannot skip over a mark, this is not always possible.
Grouping Commands
A subvalue mark (CTRL+\) lets you put more than one Proc command on the same line. For example:
001 PQN 002 10 T "ENTER FILE NAME",+ 003 IBP:%1 005 F-C 1 006 F-O 1 %1 007 T "CANNOT OPEN '",%1,"'..."\GO 10
In this example, if the requested file cannot be opened, a message is displayed on your terminal and a branch is taken to the beginning of the Proc. Grouping statements this way also makes the Proc more efficient, because any branch instruction does not need to parse extra commands in looking for a mark or label. The following limitations apply:
- File I/O commands, two line conditional commands and some others cannot be followed by another command on the same line; these are listed in Multiple Commands.
-
If a mark is used with the CTRL+\, it must be the first Proc command in the series. For example, use:
M\IBP:%1\IF # %1 X
not:
IBP:%1\M\IF # %1 X
Compiling a Proc
Although Proc is an interpretive language, Procs can be compiled using the PQ-COMPILE command. Compiling strips out text from comments and translates branch addresses to an absolute displacement, thereby increasing the speed of execution.
Chaining Procs
With the exception of chaining in order to keep MD entries brief, chaining should be kept to a minimum, because it is expensive in terms of efficiency.
Structuring Procs
To increase readability and make it easier to edit and debug your Proc, you might wish to indent lines. Leading blanks are acceptable. However, keep in mind two things:
- Leading blanks before labels are not acceptable.
- Leading blanks add to the length of the code and reduce the efficiency of the program.
You can overcome the latter objection if you PQ-COMPILE the Proc. PQ-COMPILE strips out leading, trailing and embedded blanks.
The sample Procs shown in Proc Examples are structured by indenting.