Programming Hints

Using System Delimiters

Reality uses standard attribute, value and subvalue delimiters. These should be referenced using the predefined symbols @AM, @VM and @SM (or @SVM).

Cursor Positioning

Reality uses standard Cursor Positioning Characters. It is recommended that these are EQUATE'd to symbol names, then they can be referenced in a program by their symbol name. For example:

EQU UP TO CHAR(26)
EQU DOWN TO CHAR(10)
EQU LEFT TO CHAR(21)
EQU RIGHT TO CHAR(6)
EQU BELL TO CHAR(7)

Of course, you can use extended cursor addressing such as, @(-10), for all of the above. However, the extended cursor addressing symbols can only be assigned to variables; they cannot be EQUATE'd to a symbol.

Opening Files

The OPEN statement is very time-consuming and should be executed as few times as possible. All files should be opened to file variables at the beginning of the program; access to the files can then be performed by referencing the file variables.

Repeating Operations

Operations should be predefined rather than repetitively performed. This operation, for example:

X= SPACE(9-LEN(OCONV(COST,'MD4'))):OCONV(COST,'MD4')

should be written as follows:

E= OCONV(COST,'MD4')
S= SPACE(9-LEN(E))
X= S:E

The same is true for the following operation:

FOR I=1 TO X*Y+Z(20)
 .
 .
 .
NEXT I

This should be written as follows:

TEMP=X*Y+Z(20)
FOR I=1 TO TEMP
 .
 .
 .
NEXT I

Unknown Number of Values

The following LOOP statement could be used to access an unknown number of values from an attribute (including null values):

EQU VM TO CHAR(253)
READV ATTR FROM ID, ATTNO ELSE STOP
VNO=0
LOOP
VNO=VNO+1
VALUE=FIELD(ATTR,VM,VNO)
WHILE COL2() #0 DO
PRINT VALUE
REPEAT

Modifying a Program

There are three simple preliminary steps which will simplify the task of modifying a program, especially if it has been changed and added to since it was first written. In such circumstances, it is necessary to sort all of the variables used in the program into a meaningful order so that the program's structure and method of operation are more apparent.

Having performed these three steps, you will be better prepared to start making changes to the program.