next up previous contents
Next: General I/O Up: FORMAT statements Previous: General Discussion

   
Summary

This section summarises the discussion in 9.1 and introduces some new field descriptors.

1.
The general form of a FORMAT statement is :-
label FORMAT (list of field descriptors and /s)
(The I/O statement refers to the FORMAT statement to be used during I/O by giving the label of the FORMAT statement).
2.
When outputting directly or indirectly (via a file) to a terminal or printer, the FORMAT must have a carriage control for every record produced. The most common carriage control characters are:-
     ' '   start next line
     '0'   miss one line and start next line
     '1'   start next page
     '+'   remain on current line

Carriage control characters must not be used on input.

3.
Transmission of data is controlled by the I/O list of the I/O statement. The conversion of the data is controlled by field descriptors in the FORMAT statement. Transmission ceases when the I/O list is complete and either the end of the FORMAT is reached or a field descriptor requiring another element of the I/O list is encountered. Should the FORMAT be exhausted before the I/O list is complete then an end of record is generated and the FORMAT repeated.
4.
The end of record character / may appear anywhere to terminate the current record (i.e. line of input or output) and start the next.
5.
Output FORMAT statements can contain character strings inside quotes e.g. 'ABC'.
6.
The general form of field descriptors is :-
kan.m
where :-
k
is an optional repeat count. If omitted k=1 assumed.
a
is a letter indicating the type of descriptor.
n
is a field width i.e. the number of characters used to represent the data.
m
is the number of places after the decimal point (reals) or the minimum number of non-blank characters (integers).
The most commonly used field descriptors are listed below :-

Im.n
Integer with at least n non blank characters. The .n is optional (and is only allowed on the VMS). Omit m.n on input for variable width (but terminate data with a comma)

Fm.n
Real with n digits after decimal point. On input the .n is ignored if a decimal point is given. Also on input can handle real with an exponent e.g. 1.2E-5. Omit m.n for variable width input (but terminate data with a comma and include a decimal point.).

Em.n
Same as Fm.n but on output exponent is displayed.
Gm.n
A combined form of Em.n and Fm.n allowing output in F format where [possible] but switching to E format if too much precision would be lost.

Om.n
Same as Im.n but display in octal. Only allowed on the VMS. See section 17.

Zm.n
Same as Im.n but display in hexadecimal. See section 17

Lm
Logical data. See section 12

Am
Character data. See section 11

kX
Skip k characters on input or produce K spaces on output.

Tm
Tabulate to the mth character in the data record.

7.
Brackets may appear in FORMAT statements preceeded by a repeat count to repeat a group of descriptors.
8.
Use $ on output FORMATs to suppress the carriage return. (VMS only).


next up previous contents
Next: General I/O Up: FORMAT statements Previous: General Discussion
n west (APC)
2000-03-08