definestat ::=DEFINE deflist; deflist ::=identifier=defexpr|deflist, identifier=defexpr defexpr ::=defprim|defprim aop defbasic defprim ::=defbasic|$fixedcellidentifier|@fcd-@fcd| £cellidentifier-£cellidentifier| @instruction identifier-@instruction identifier aop ::=+|-|*|/ defbasic ::=integer|identifier (where identifier has previously been defined) fed ::=integer|identifier(integer)|identifer(-integer) conditcomp ::=?integer(section of program)?integer (where the two integers are the same and in the range 1-10 inclusive. There must be no spaces between the ?, the integer and the parentheses) includestatement::=INCLUDE(subfilename)|INCLUDE(subfilename, SL) subfilename ::=identifier . identifier instridentifier::=lidentifier|pidentifier
The define statement provides a means of associating an absolute integer value with an identifier at compile time. An identifier defined in this way may then be used at any point at which the corresponding integer value would be valid.
NB. The identifier does not label a storage cell, and cannot therefore be assigned to or altered in any way by the program. For example, consider the following section of code:
LOWER INTEGER TABLE1(10) = (0*10),TABLE2(10); ............................. FOR X1:=0 STEP 1 UNTIL 9 DO BEGIN X6:=TABLE1(X1);TABLE2(X1):=TABLE2(X1)+X6;END;
If the size of the tables is later altered, at least four alterations must be made to the program code. If, however, the code was:
DEFINE N=10,P=N-1; LOWER INTEGER TABLE1(N) = (0*N),TABLE2(N): ................................ FOR X1:=0 STEP 1 UNTIL P DO ......
only the DEFINE statement would need to be altered.
The forms of expression which may be used in DEFINE statements are:
DEFINE A=3,B=#100CNT,C='XYZ',D=B;
DEFINE E=$TABLE1(1),F=$TABLE2;the value given is the displacement of the cell considered as a number of words,
DEFINE G=£TABLE2-£TABLE1;H=@TABLE2-(@TABLE1(3);each pair of cells must be both in upper or both in lower storage, also both must be in the same common block or neither must be in common.
DEFINE I=@SIN-@COS;where SIN and COS are either procedure or label identifiers.
+ - * /and the operands must be literals or previously defined identifiers. The operations are carried out from left to right, and all intermediate and final results must be single length integer values, for example:
DEFINE J=A+1/2*'?';In this case, if (A+1)/2 is not an exact integer it will be rounded down.
Sections of code can be included in a program, and either compiled or ignored according to the setting of bits in the switch word. For example, the line of code:
?1( X4:=A ?2( +B ?3( -C )?3 )?2 ?3( *D )?3 ; )?1
will have the following effect:
Switch 1 Switch 2 Switch 3 Code Compiled off on/off on/off none on off off X4:=A; on off on X4:=A*D; on on off X4:=A+B; on on on X4:=A+B-C*D;
Note that the scopes of conditional brackets may be nested and may even overlap, but that in the case of overlapping scopes the effect achieved may not be that intended.
For example, it is permissible to write:
?1(JOE;?2(SID;)?1FRED;)?2
but the effect is as follows:
Switch 1 Switch 2 Code Compiled off off FRED; off on FRED; on off JOE; on on JOE;SID;FRED;
The use of the INCLUDE statement, which must appear on a line by itself, causes the contents of the specified subfile to be compiled as if they appeared at that point in the program. The contents of the subfile may be any number of statements or declarations, or even parts of statements These may not include further INCLUDE statements. If the parameter SL is given, the subfile code is shortlisted, if not it is listed as if it were part of the main program file except that the lines will not be numbered.
A situation in which the INCLUDE facility would be useful is where a large global declaration is required in several segments. In this case the global declaration could be placed in a subfile and included wherever required. If INCLUDE statements are to be used in a program then a MACROFILE or PUBLICFILE directive must be given, and the file containing the text to be included must be assigned to the compiler. Note, if the macrofile is empty this will cause the compiler to fail.
Source text can be placed in subfile form in direct access files by use of the utility program #XMED, which is described in the Compiling Systems Manual. Note that there is no subfile parameter which specifies the language PLASYD. The parameters *FORTRAN, *EMA, or *ALGOL can be used instead. The program #XMED may be found in a file entitled :SUBLIB.PROGRAM XMED, and an example of a simple job using it is given in Appendix 4.