1. The following is the method of variable control that has been chosen for the initial implementation. It concludes the discussions set out in Notes 8, 9 and 10.
1.1 All variables will be referenced by names rather than numbers. Thus PR, AR will have text as arguments.
1.2 Global names will be hashed into a name table. The real number representation of the name will be stored in STORE mode.
1.3 Local variables must be declared at the head of the file which references them (via a routine LOCAL). During file storage, the names will be replaced by negative pointers to the local locations. The number of local variables used in a file will be stored in the file header.
1.4 Local variables to be used as dummy arguments will also be declared (via routine LOCARG). All dummy arguments must be declared before local workspace variables. The number of arguments used in a file will also be stored in the file header.
1.5 Arguments are passed using two routines (ARG and ARGN). If ARGN is used, the argument is passed by name. ARG passes the argument by value. If the argument is called by name, its value is updated at the end of the file (on meeting FIDF).
1.6 Local variables and arguments will be stored in a Variable Stack. The routines ADSOLL and ADSOLG will have an extra argument giving the maximum amount of local workspace required by the specified sequence list item. DRAW will cause a standard amount of workspace to be allocated (as will using a negative value for the workspace size in ADSQLL etc). A new routine, STSQLS, will have the sane effect as DRAW, but will allow the total amount of workspace required for this item to be specified (and so will have two arguments). STSQLS will not be a display routine.
Within the workspace for each sequence item, space for local variables and arguments will be allocated as each file is entered, and the space will be released when the file terminates. Two words are allocated to each dummy argument: the first is the value, the second is the address of the actual argument. ARGN will plant the value and address, ready for the next file. ARG will plant a zero address to indicate call by value. Each local variable will be allocated one word for its value.
When the file terminates, all arguments that have been called by name will have their values updated. Care must therefore be taken if global variables are used explicitly in a file and are also used as arguments to that file.
1.7 The routine ALOCAL ill take its text argument to be a reference to a local variable and return a local variable address (negative pointer). This will allow a variable to contain the address of a local variable for index purposes.
Example
LOAD (ANAME('X'),ANAME('Y')) LOAD (ANAME('X'),ALOCAL('Y'))
The first routine call loads variable X with the real number representation of Y. Hence the contents of X is a reference to the global variable Y. The second routine call loads variable X with a negative pointer to the local variable called Y.
1.8 The function AR will now have three arguments, indicating the names of three variables containing file name, file number and pointer. The value of the function will be a pointer to a table in which the addresses of the three variables will be stored temporarily. These addresses will either be planted in the file (STORE mode) or RCNCL will access this local table to obtain the required data (note p.2(d)).
1.9 Examples
STDF (ANAME ('FRED') LOAD (ANAME('X'),2.0) FIDF (1.0)
This is a reference to the global variable X. The real number form of the X will be stored.
STDF (ANAME ('FRED')) LOCAL,('X') LOAD (ANAME('X'),2.0) FIDF(1.0)
This is a reference to a dummy argument X. The address of X will be as for local variables, but if FRED is called with ARGN:
ARGN(ANAME('X')) DRAW(ANAME ('FRED'))
then the variable Z will be updated on exit from FRED.
STDF(ANAME('FRED')) LOCARG ('Y') LOCAL('Z') TOX(AR1('X','Y','Z')) FIDF (1.0)
This is an example of an array reference. The file name is specified by the global variable X, the file number by the dummy argument Y and the file pointer by the local variable Z. The reference will be stored as the three addresses of X, Y and Z together with the correct bit setting of IPRMV.