Scor­pio News


January–March 1987 – Volume 1. Issue 1.

Page 16 of 63

where u is the physical or logical unit number, f is the statement label of the dated FORMAT statement and k is a list of variable names, separated by commas although it is optionally possible to use the form:

READ (u,f,​ERR=L1,​END=L2) k       or       WRITE (u,f,​ERR=?L1) k

where L1 is the label of the statement to which control is passed in the event of an I/O ERROR and L2 the statement label to which control is passed if an END OF FILE is encountered. These are extensions of data I/O not found in the 1966 standard).

The Logical Unit Numbers referred to above are normally assigned as follows:

Units 1, 3, 4 and 5 are assigned to the console/VDU; Unit 2 is assigned to the printer. ;Units 6 – 10 are assigned to disk files. Units 11 – 255 may be assigned as the user wishes (and units 1 – 10 may also be re-assigned if you really want to!)

For most purposes the default assignments will be found adequate but for further information, the appropriate reference manual must be consulted.

A typical READ statement will Look like:

   READ(5,35) K,L
35 FORMAT(I3,2X,I4)

An which two data entries, K and L are read in from the keyboard with field widths of 3 and 4 respectively, separated by a blank field of 2 spaces. The same holds for a WRITE statement since, if it is in the same program subroutine,

   WRITE(2,35) K,L

will cause the values of K and L to be output on the printer, starting in column 1 and separated by 2 spaces. Statement numbers muse not be duplicated in the same subroutine but more than one READ/​WRITE statement may reference a given FORMAT statement.

Alphanumeric text material (letters, symbols and figures) may be used as program I/O by means of a FORMAT statement in one of two ways which employ Hollerith field descriptors the first (and less convenient) method involves the programmer in counting the exact number of characters and spaces to be input or output – tedious for long titles, while the other simply involves placing the entire text between single quotes ('). In both cases, the program statement must not run beyond column 72; if a longer text string is needed, then a continuation line if used. The statements:

    WRITE(6,200) L


    WRITE(6,100) L

are treated in the same way by the compiler but the first uses the Hollerith (H) field width descriptor – 20 unite wide in this case and the same as the text including spaces while the second uses single quotes as text delimiters – a lot easier to use! The expressions mean ‘write to a disk file the text followed by the current value of the variable L’.

On both input and output, text can be split between lines by using the solidus (/). As far as input is concerned, this applies to disk input data files as well as to punched cards or paper tape – both of which are unlikely input media for the average micro user. The first example given above could be rewritten as:

Page 16 of 63