This chapter describes the method of handling input and output by the Supervisor, and gives details of the input and output procedures provided by the Atlas 1 compiler.
All input and output is handled by the Supervisor. The Supervisor reads a program or data document (see Chapter 1) from a peripheral, converts it if required into Atlas Internal Code, and puts it in the input well. The document is read from the well by the compiler (if it is a program document) or by the program (if it is data). Each input document has a stream number, specified in the job description (see Chapter 1); different documents are selected by the procedure 'select input' (see section 5.2.1).
Output is handled similarly. An object program builds up output documents, and when the job is terminated each document is put separately in the output well before being sent to the appropriate peripheral, and they will be output separately. Each output document has a number, specified in the job description; different documents are selected by the procedure 'select output' (see section 5.2.1).
All procedures for handling input and output of data are procedures defined in the strict Algol sense: that is to say, although the procedure bodies are expressed in non-Algol language, the procedure headings are normal Algol headings containing an identifier and (usually) a formal parameter list and specification part. As far as the user is concerned, calls of these procedures will be written exactly the same way as calls of any Algol procedures, communication being effected by the substitution of actual for formal parameters in the customary manner. This approach is in accord with the spirit and letter of the Algol 60 report, and specifically excludes, for example, output procedures having a variable number of parameters.
The identifier chosen for each procedure is a reserved identifier only in the sense that, if a program does not specifically declare a procedure denoted by the same identifier, then the standard procedure will be incorporated if required.
Document numbers are associated with particular documents by a job description, as required by the Atlas Supervisor (see Chapter 1). The only reference to document numbers (stream numbers) within an Algol program are made by two selection procedures, having the following headings.
procedureselect input (n); value n ; integer n; comment A call of this procedure selects input document n: subsequent calls of input procedures take information from document n unless and until a further call of this procedure selects a different document;
procedureselect output (n); value n ; integer n; comment A call of this procedure selects output document n: subsequent calls of output procedures put information to document n unless and until a further call of this procedure selects a different document;
Only one input document and one output document may be currently selected. If an input procedure is called before a document has been selected, input 0 is presumed. Output is similarly treated. Selection of a document not defined in the job description will cause the program to be monitored (see section 3-2).
Numbers may be read by use of the function designator 'read' having the following procedure heading.
real procedure read; | comment A call of this procedure provides the value of the next available number from the currently selected input document;
Any number as defined by (2.5) is acceptable; the character α is used as the hardware representation of the basic symbol 10 (on some Flexowriters α appears as the single character 10). Numbers may be terminated by 2 blank spaces, a newline, a comma or a semi-colon. Single blank spaces are ignored everywhere; multiple blank spaces and newlines are ignored before the start of a number, or following the occurrence of the character and before the start of an exponent - otherwise 2 blank spaces act as a terminator.
The occurrence of any character other than the digits 0 to 9, the characters . + - and α, or a comma or semi-colon will cause the program to be terminated. Termination will also occur if a number is out of range, or in the event of a fault in the form of a number such as more than one decimal point or sign, or the character α or a decimal point in an exponent, and so on.
Truth values may be read by the function designator 'read Boolean', having the following procedure heading.
Boolean procedure read Boolean; comment A call of this procedure initiates a search, from the current position in the currently selected input document, looking for one of the composite characters t and f, ignoring any intervening basic symbols, spaces, or newlines: when t or f is found, the procedure checks that it is part of the basic symbol true or false and returns the corresponding value;
Output of a number to a straightforward specified format is performed by the procedure 'print'. (The effect of this procedure is very similar to that of the PRINT instruction in Mercury Autocode.)
procedure print(quantity, m, n); value quantity, m, n; real quantity; integer m, n; comment Outputs to the currently selected output document the numerical value of quantity to a decimal format determined by the values of m and n, followed by two blank spaces;
This procedure outputs a number to the line currently being assembled, without carriage control characters; control of the horizontal and vertical layout of a printed page is obtained by use of the 'write text' procedure and the three layout procedures described in section 5.2.5.
The format is determined by the values of m and n as follows, (In each case the total count of character positions includes the two blank spaces following the number.)
If m = 0 and n ≠ 0 a standardised floating decimal number of the form d α e is printed with n decimal places in the mantissa d (1 ≤ d < 10) and a three digit exponent e, occupying n + 10 character positions in all.
If m ≠0 and n ≠ 0 the number is printed in fixed-point form with m figures before the decimal point and n figures after the point, occupying m+n+4 character positions in all.
If m ≠ 0 and n = 0 the number is printed as an integer occupying m+3 character positions in all.
This procedure rounds off the decimal form of the number, suppresses non-significant zeros, and prints negative signs only, immediately preceding the first printed digit.
If (when m ≠ 0) a number will not fit the specified field, further character positions will be used to accommodate it. Horizontal spacing of results on the remainder of the line will then be spoilt.
Example of typical output:
m = 0, n = 5 -5.12796 1 -3.21478 -12 2.22395 0 m = 3, n = 2 17.56 -921.80 -0.97 0.00 m = 5, n = 0 0 -37 -15624
procedure output(quantity); value quantity; real quantity; comment outputs to the currently selected output document the value of quantity in a standard floating-point form, followed by a semi-colon and a newline character. The layout is that produced by output of the number by a call of procedure 'print' with m = 0, n = 10;
Output of the values of Boolean expressions is performed by the procedure 'write Boolean', having the following heading:-
procedure write Boolean (quantity); value quantity; Boolean quantity; comment outputs to the currently selected output document the value of the Boolean quantity as the symbol true followed by two blank spaces or the symbol false followed by one blank space;
procedure write text(string); string string; comment Outputs to the currently selected output document the given string of basic symbols, with the exception of particular layout editing characters enclosed in further string quotes, which are specially interpreted; the hardware representations of the Algol string quote symbols are '(BS-' and ')BS-' and that of space is 'sBS/' ;
There are three editing characters, each of which may be preceded by an unsigned integer denoting a required number of repetitions; their meaning is as follows:
c newline (carriage return, line feed) p page change (paper throw) s blank space
Example of use To output on the second line of a new page the heading
CASE B BOUNDARY LAYER EFFECTS EXCLUDED
and to leave two blank lines before the start of the next printed output, the following statement may be used.
write text ( (BS-(BS-pc)BS- CASEsBS/B(BS-10s)BS-BOUDARYsBS/LAYERsBS/EFFECTSsBS/EXCLUDED(BS-3c)BS-)BS-);
It is permissible for editing characters to be the only symbols in the string supplied as parameter to the 'write text' procedure; for example :-
write text ((BS-(BS-3c)BS-)BS-);
which is equivalent to the statement
newline (3);
or
write text((BS-(BS-c25s)BS-)BS-);
which is equivalent to the two statements
newline (1); space (25);
Three procedures provide control of the layout of printed results; they have the following procedure headings :-
procedure space(n); value n; integer n; comment outputs to the currently selected output document n blank space characters;
procedure newline(n); value n; integer n; comment outputs to the currently selected output document n newline characters;
procedure paper throw; comment outputs to the currently selected output document the character required to initiate a paper throw to the head of a new page ;