So far, picture and film files have been defined in a fairly rigid form. By redefining the position of regions or changing the selected region, it has been possible to vary the result of the executed file. However, no major alterations have been possible. In order to add greater flexibility, index variables have been defined, so that references to them may be stored in a file, and values given at file execution time.
A set of 256 global variables is available to a user, each variable being capable of holding a single length floating point number. These variables can be given names using ANAME in the same way as files, but it is advisable to restrict the form of a global name to alphanumeric characters. These variables behave like index registers, in that they provide a means of indirection in the value of a display routine argument.
A set of functions, PRn(ANAME('XIND')), has been defined, one function for each possible argument position. Thus:
VEC (1.0, PR2(ANAME('XIND1')), 3.0, PR4(ANAME('XIND2')))
will draw a line between (I,XIND1) and (3,XIND2) where XIND1, XIND2 are the values currently held in the two specified index variables. The above format is necessary to keep within the definition of FORTRAN, but a simpler format is available if the preprocessor is used (see Chapter 13).
Global variables are used mainly with files.
Thus:
STDF(ANAME ('PICT')) SETXY (PR1(ANAME ('XIND1')), PR2(ANAME('XIND2'))) TODX (1.0) TODY (PR1(ANAME('XIND3'))) FIDF (1.0)
will define a picture file consisting of two lines, one horizontal of constant length, the other vertical of variable length. The left hand end of the horizontal line is determined by the values in XIND1,XIND2.
A set of display routines has been defined to perform arithmetic on global variables at run time.
Routine | Action |
---|---|
LOAD (ANAME('XIND'),VAL) | XIND=VAL |
ADD (ANAME('XIND'),VAL) | XIND=XIND+VAL |
SUB (ANAME('XIND'),VAL) | XIND=XIND-VAL |
MPY (ANAME('XIND'),VAL) | XIND=XIND*VAL |
DVD (ANAME('XIND'),VAL) | XIND=XIND/VAL |
POW (ANAME('XIND'),VAL) | XIND=XIND**VAL |
NEG (ANAME('XIND')) | XIND=-XIND |
In addition, the following arithmetic functions are available: | |
SINX (ANAME('XIND'),VAL) | XIND=SIN(VAL) |
COSX (ANAME('XIND'),VAL) | XIND=COS (VAL) |
LOGX (ANAME('XIND'),VAL) | XIND=ALOG(VAL) |
EXPX (ANAME('XIND'),VAL) | XIND=EXP(VAL) |
In the above, of course, either argument can be replaced by an index variable reference (PR) to add to the function capability.
LOAD (ANAME('XIND3'),0.0) LOAD (ANAME('XIND1'),1.0) LOAD (ANAME('XIND2'),1.0) DO 10 I = 1,50 ADD (ANAME('XIND3'),1.0) DRAW (ANAME('PICT')) ADVFLM 10 CONTINUE
will draw lines between (1,1) and (2,1), and between (2,1) and (2,X+1) on the next 50 frames, with X increasing from 1 on the first frame to 50 on the last.
A number of display routines have been defined to give access to the current region parameters and the current X,Y position. These system variables are read in to the specified index variables.
Routine | Parameter |
---|---|
RDREG (ANAME('XR')) | current region number |
RDLIM (ANAME('X1'),ANAME ('Y1'),ANAME('X2'),ANAME('Y2')) | current region limits |
RDPLIM (ANAME('XR'),ANAME('XP1'),ANAME ('YP1'),ANAME('XP2'),ANAME('YP2')) | current RGPLIM limits |
RDSHAP (ANAME('XCNV'),ANAME('XBSC ')) | current region shape |
RDVISO (ANAME('XVI' ),ANAME( 'XVO')) | current region visibility |
RDBASE (ANAME('XSW')) | current region device setting |
RDXY (ANAME('XP'),ANAME('YP')) | current values of XPOS,YPOS |
It is possible to define a file, which contains data only, by using the display routine:
NULL (X)
Files containing only NULL commands are termed NULL files. It is possible to read data from NULL files using global variables, and use the data as arguments to display routines. The functions:
ARn (ANAME('F1'),ANAME ('FNO'),ANAME('NT'))
(one for each argument position like PRn), specify three global variables. The first two contain the file name and number of a NULL file, and the third is a pointer into the file. The filename is in its real number form.
Thus:
STDF (ANAME('PATH')) NULL (1.0) NULL (2.0) NULL (3.0) NULL (4.0) FIDF (1.0)
defines a NULL file, and the file:
STDF (ANAME('LINE')) SETXY (AR1(ANAME('FI'),ANAME('FNO'),ANAME('PNT')) ,0.0) TODXY (0.0,1.0) FIDF (1.0)
will, when executed, draw a line from a point whose X coordinate will be found in the file defined by F1,FNO at position PNT.
Thus:
LOAD (ANAME('F1'),ANAME('PATH')) LOAD (ANAME('FNO'),1,0) LOAD (ANAME('PNT'),0.0) DO 10 I=1,4 ADD (ANAME('PNT'),1.0) DRAW (ANAME('LINE')) 10 CONTINUE
will generate a series of lines, starting at (1.0),(2,0),(4,0) and (8,0) respectively.
Attempts to access beyond the bounds of the NULL file will always give the value 0.0.
Although not strictly related to index variables, it seems natural here to develop the idea of NULL files further. It is possible to give meaning to a NULL routine within a file by using:
NULSET (ANAME('DPRTN'))
where DPRTN is the text name of a display routine.
If NULL is used outside a file, an error will result. Inside a file, however, NULL will be treated as a call to routine DPRTN. If this routine requires more than one parameter, the system will take extra parameters from following NULLs, (or fill up with 0.0 if no more NULLs are present).
Thus:
NULSET (ANAME('TOXY')) DRAW (ANAME ('PATH'))
is equivalent to:
TOXY (1.0,1 .0) TOXY (4.0,8.0)
and:
NULSET (ANAME('VEC')) DRAW (ANAME('PATH'))
is equivalent to:
VEC (1.0,2.0,4.0,8.0)
DPRTN may not be NULL, FIDF or ADVFLM.