A more flexible format for the output of data can be obtained by using the KDF9 write procedure than any available in the standard ICT set of I/O procedures. This procedure has therefore been defined as ICT22.
procedure write kdf9 (F, Q); value F,Q; integer F; real Q;
This procedure outputs the quantity Q in a form which depends on the format F. The value of F must be set to the result of calling the function procedure:-
integer procedure format(S); string S;
The string S is set up as a pattern showing the form that the number should take on the output media.
<initial>spaces ::= <empty> | <unsigned integer> s| |s |ss | sss | ssss | sssss | ........ | sssssssssssssss <sign> ::= <empty>|-|+|≠ <exponent sign> ::= -|+|≠ <exponent layout> ::= 10<exponent sign> nd <terminator> ::= <empty> | ; <editing symbols> ::= <empty> | c | cc | ccc | p <zeros> ::= 0 | <zeros> 0 | <zeros> s | s <zeros> <positions> ::= d | <positions> d | <positions> s | s <positions> <fractional layout> ::= .<positions> <floating layout> ::= d <fractional layout> <digit layout> ::= <positions> | <fractional layout>| <positions> <zeros> | <positions> . <zeros> | <positions> <fractional layout> <zeros> | <positions> <fractional layout> | <positions> <zeros>. <zeros> <decimal layout> ::= <digit layout> | n <digit layout> | s <decimal layout> <layout tail> ::= <decimal layout> <terminator> <editing symbol> | <floating layout> <exponent layout> <terminator> <editing symbol> <layout> ::= <initial spaces> <sign> <layout tail> <format identifier> ::= <identifier> <format statement> ::= <format identifier> := format ( '<layout>')
A different integer identifier is used for each format required. This identifier is then used as a parameter to a write kdf9 statement.
Tfle symbols of the layout give a picture of the digits, spaces and symbols as they will appear on the printed sheet. The finally printed number will have exactly the same number of printed characters as is present in the layout (except in the case of alarm printing and the characters c, p and the special case if initial spaces). The various symbols of the layout have the following significance:
Alarm printing will occur when the number is too large for the layout or a negative number occurs with a layout having an empty sign position. Alarm printing will also occur if the format is syntactically incorrect. The number will be printed in standard floating format marked with an asterisk as follows:
*≠d.ddddsddddsddds ≠nddc
The alarm printed number will be on a new line followed by another new line with the appropriate number of spaces, so that the overall layout is not disturbed.
For example:-
i := format ('≠ndd.d'); write kdf9 (i, 37.28); or alternatively write kdf9 (format ('≠ndd.d'), 37.28); would output +37.3
ICT22 comprises the two procedures write kdf9 and format.
This consists of the two procedures:-
integer procedure char in kdf9; procedure char out kdf9(C); value C; integer C;
The procedure char in kdf9 will read the next character of the selected data stream and the Atlas internal code value of this character will be the result of the procedure. For example reading the digit 1 gives the result 17 and A gives the result 33. The case shift causes 64 to be added to the internal code value. Reading a, for example, has the resulting value 97.
The procedure char out kdf9 will output to the selected output stream the character having internal code number C.
These two procedures are particularly useful for testing for the appearance of certain characters on the input and the output of unusual forms.
procedure copy text kdf9(S); string S;
This procedure causes characters to be copied from the selected input to the selected output. If the string S consists of a single character then copying will take place from the current position of the input stream and will continue until the character in S is encountered. If the string S consists of two characters then all characters on the input preceding the appearance of the first character are ignored. Copying then takes place until the appearance of the second character in the string. The characters in S which indicate the start and finish of the text to be copied will not themselves be copied.
procedure read array kdf9(A, S); real array A; string S;
This procedure will read from the currently selected input an array A punched in the following form:
S; w; d; m1; m2; m3;........md; element; element; ........;element;
The symbols have the following significance:
If w = 1, the order in which the elements are expected from the tape is that given by first taking the lower bound values of the first (d-1) subscripts, and taking the dth subscript through its range from lower bound to upper bound; then stepping on the (d-1 )th subscript and taking the dth again through its range; and proceeding thus through the subscripts from right to left. In the case of a two-dimensional array regarded as a matrix, this is reading the elements by rows.
If w = -1, the subscripts are worked through from left to right. For a matrix this is reading the elements by columns. This is regarded as the usual form, rather than reading by rows.
d is the number of subscripts. (d = 2 for a matrix.)
mr is the range of the rth subscript.
procedure write array kdf9(F, D, A, S); value F, D; integer F, D; real array A; string S;
The array name S is output on the currently selected output followed by the initial parameters necessary for reading the array back in again using ICT25. Following this, the elements of the array are printed in columns.
The library item ICT27 consists of the four Elliott procedures:- address, lowbound, range and size. These four procedures allow the user access to all the information in the array's dope vector. They can be used to generate efficient array handling in code procedures.
integer procedure address(A); array A;
The result of this procedure is the address of the first element of the array A.
integer procedure lowbound(A, I); value I; array A; integer I;
The result is set to the lower subscript bound for the Ith subscript position from the left in the array A.
integer procedure range(A, I); value I; array A; integer I;
The result is the number of array elements in the range of the Ith subscript position from the left in the array A.
integer procedure size(A); array A;
The result is the number of elements In the array A.
For example the address of the array element A[I,J] is:-
(I _- lowbound (A,1)) * range (A,2) + J - lowbound (A,2) + address (A)
procedure advance elliott;
This procedure advances the currently selected input stream over the next character.
Boolean procedure buffer elliott(S); string S;
The value of this Boolean function is true if the next character to be read on the currently selected input is the same as the single character defined as the string S; otherwise the result is false.