The input and output of data will generally be accomplished by means of permanent routines. In this section these permanent routines are described and the precise form of data is given.
The selection of an input channel is performed by the routine:-
routine spec select input (integer i)
This selects the input channel corresponding to the value of i, and this channel, together with the particular input device assigned to it in the Job Description (see Section 7), remains selected until another select input instruction is encountered.
Output channels are selected in a similar way, by means of the routine:
routine spec select output (integer i)
In both cases channel 0 is initially selected, and in the absence of a channel selection instruction, remains selected during the execution of a program.
Decimal numbers may be read from a data tape by means of the routine
routine spec read([VARIABLE])
This reads a decimal number from the currently selected data channel and places it in the location specified by the [VARIABLE], which may be of type integer or real. The routine reads numbers in either fixed or floating point form, for example:-
-0.3101 18 7.132α-7 3.1872α14
A number is terminated by any character other than a decimal digit, the first decimal point, or an exponent. An exponent consists of a followed by an optional number of spaces, an optional sign, and the decimal digits. Spaces and newlines proceeding a number are ignored, but all other symbols cause the routine to signal a fault (but see NOTE at the end of this section). A fault is also indicated if a number assigned to an integer variable is not integral.
It should be noted that a single space is sufficient to terminate a number, and that no spaces are allowed within the mantissa or within the numerical part of the exponent (unlike constants appearing in a program where all spaces are irrelevant and the number is terminated by the following name or delimiter). Further since tabs are converted to a number of spaces, numbers may be separated by tabs. Several numbers in a sequence may be read by the routine:-
routine spec read([VARIABLE LIST])
For example, read(a,i,X(i))
This is treated as if it were a series of instructions
read (a) ; read(i) ; read(X(i))
hence the subscript of X(i) takes the value just assigned to i.
The read routine is an exception to the general form of a routine, as it may have an indefinite number of real name and integer name parameters.
Successive numbers on a data tape may be read so as to fill an array by means of the routine
routine spec read array(arrayname A)
For example:-
array A(1:20, 1:20) read array (A)
would cause the next 400 numbers on the data tape to be read so as to fill the array A, row by row. It is thus equivalent to
array A(1:20, 1:20) integer i,j cycle i = 1,1,20 cycle j = 1,1,20 read (A(i,j)) repeat repeat
Three permanent routines are provided for manipulating alpha-numeric data. The first:-
routine spec read symbol (integername i)
reads the next symbol (simple or compound) from the selected channel, converts it into a numerical equivalent and places the result in the the specified integer location.
For example, if the next character on the data tape were an asterisk (numerical equivalent 14) the instruction 'read symbol (p)' would set the value of the integer variable p to 14 and move to the next character on tape.
The second allows the next symbol on the data tape to be inspected without moving on to the following one. It is
integer fn spec next symbol
The third:-
routine spec skip symbol
passes over the next symbol without reading it.
A table of numerical equivalents and a description of the formation of compound symbols is given in Appendix 5.
It is in testing symbols that the alternative form of a constant is useful. For example, we could test if the next symbol on a tape were an asterisk by
->1 if next symbol = 14 or ->1 if next symbol = '*'
Since spaces and underlined spaces are ignored in a program, and newline and semicolon are used as terminators, special symbols are provided to represent them. Thus a space can be tested for by
->1 if next symbol = 's'
The symbols are:-
s representing a space s representing an underlined space n representing a newline
If the data itself contains these special symbols, then they can be tested only by using the internal equivalent.
Finally there is a permanent input routine which permits the reading of an indefinite number of decimal numbers into successive storage locations, stopping when a particular symbol on the data tape is reached. This routine is
routine spec read sequence (addr s, integer p, integer name n)
The formal parameter type addr is explained in Section 9; for the present purpose it is sufficient to say that the actual parameter will be the name of a variable, representing the first location into which the numbers are to go. p is the numerical equivalent of the terminating character, and on exit from the routine, n contains the number of numbers that have been read.
As an example of the use of the above routine, suppose a data tape contains an unknown number of numbers, but less than 1000, and that the last number is followed by an asterisk. Then the instructions
array X (1:1000) integer n read sequence (X(1), 14, n) [or : read sequence(X(1),'*',n)]
would cause the successive numbers to be read into X(1), X(2), etc. If there were 800 numbers in the sequence, then n would be set to 800 when the routine was left.
On input, each line of data is reconstructed to give an image of the print-out produced by the Flexowriter. Thus 'backspace','tab','upper case' and 'lower case' do not appear as characters in the reconstructed line, since they do not appear on the print-out. 'Tab' produces an equivalent number of spaces, 'backspace' helps form a composite character, and non-significant cases are ignored. Those positions containing an erase are then deleted from this line. The line image is normally 160 characters, but where the tab and backspace facilities are avoided, lines can be of any length, sections of 160 characters being taken serially.
The routines for the output of a single decimal number are
routine spec print fl (real x, integer m) routine spec print (real x, integer m,n)
The first of these prints the value of x (which may of course be a general [EXPR]) in floating point form, standardised in the range 1≤x<10, with m decimal digits after the decimal point. The number is preceded by a minus sign if negative, and a space if positive. The exponent is preceded by α and consists of a space or a minus sign and two decimal digits, the first of which is replaced by a space if it is not significant. The second routine prints the value of x in fixed point form with m digits before the decimal point and n after. Non-significant zeros, other than one immediately before the decimal point, are suppressed, and a minus sign or space precedes the first digit printed. If |x| ≥10↑m then extra digits are included before the decimal point, the effect being to spoil any vertical alignment of the printed page.
It should be noted that no terminating characters are included by the above routines. They may be included by the user by means of the routines:-
routine spec newline routine spec space routine spec newlines(integer n) routine spec spaces (integer n) routine spec tab routine spec print symbol (integer i)
The first of these resets the carriage of the appropriate printer (or punches the newline character), and the second causes the printer to skip a character position. If a number of consecutive spaces or newlines are required, the third and fourth routines may be used, for example:-
spaces (5) newlines (3)
The fifth routine punches the tab character or causes the printer to move to the next tab setting. These settings are at positions 8, 16, 24, 32, 48, 64, 80, 96, 112, 128, 144, and 159. The sixth prints the symbol corresponding to the value i.
The routine:-
routine spec newpage
causes the lineprinter to commence a new page, if the output device is a line printer, or punches 30 newline characters if it is a punch.
The routine:-
routine spec runout (integer n)
punches n runout characters (used to seperate sets of results, for example) on the punch. It has no effect if the output is on a line printer.
Arrays of numbers may be output by means of the routines
routine spec print array fl (array name A, integer m) routine spec print array (array name A, integer m,n)
For a one-dimensional array, the elements of the array are printed across the page, each number being terminated by two spaces, or a newline if the right hand edge of the page has been reached. The successive rows of a two dimensional array are printed as above, successive planes of a three dimensional array are printed as two dimensional arrays, and so on. Each array is started on a newline and the printing style for the individual numbers is the same as that of the 'print fl' and 'print' routines.
There is a special facility for printing captions. For example
caption ssss TABLE s OF s TEMP s AGAINST s VOL
This prints the information after caption up to, but not including, the terminating symbol 'newline' or 'semi-colon', since spaces and underlined space are ignored and 'newline' and 'semi-colon' are used as terminators, we also use the special characters.
Thus
newline caption A s = ss ; print (y,1,3); newline caption B s = ss ; print (2,1,3); newline
would be printed as
A = 1.712 B = -2.380
In general c can be used (in its usual sense) in a caption it the information is too long to fit on one line across the page. In view of this if an underlined word ending in c is used at the end of a caption, it must be terminated by 'semi-colon' not 'newline'.
Binary tape may be read and punched by means of the routines
routine spec read binary (integername i) routine spec punch binary (integer i)
The first reads the next row of holes on the tape as a binary number (in the range 0-127, with the tape so oriented that the sprocket hole comes between the digits of value 4 and 8), and places it in the named variable. Binary data tapes must be preceded by ***B or, if they contain characters of of even parity, by
***P ***B
The second punches the seven least significant binary digits of the integral part of the integer expression as a row of holes on the output tape.
NOTE: Cards or 5-hole tape may be used in which case the operations are on 5 or 12 digits rather than 7.