FORMAT SPECIFICATION FIELDS:
Format field | Properties | Data type |
---|---|---|
Iw[.m] | w - width m - leading zeros | Integer values |
Fw.d | w - width d - decimal point precision | Float values |
Ew.d[Ee] | w - width d - decimal point precision e - optional exponent width | Float values (Engineering mode) |
Ew.d[Ee] | w - width d - decimal point precision e - optional exponent width | Float values (Engineering mode) |
Dw.d | w - width d - decimal point precision | Double precision values |
Lw | w - width | Logical values |
A[w] | w - width | String values |
Zw | w - width | Hexadecimal values |
Ow[.m] | w - width m - leading zeros | l values |
"a" or 'a' | a - string sequence | Outputs the string sequence |
nX | n - number of spaces | Outputs n space characters |
nH | n - number of chars | Hollerith constant - Outputs the next n characters |
$ | Doesn't output line break |
HOW TO USE:
How to use the format statement and its format specification fields? One way you declare a FORMAT statement is something like below:
r FORMAT (f1,f2,...,fn)
r - Label number
f1,f2,...,fn - format specification fields
Its easy to use it, the only thing you must remember is the label number r.
PRINT r,e1,e2,...,en
WRITE (unit, r) e1,e2,...,en
READ r,e1,e2,...,en
READ (unit, r),e1,e2,...,en
Where e1,e2,...,en are expressions matching each one a format specification field.
The other way to declare the format specification fields is explicitly writing it. You change the label number by a quoted format specifications fields like below.
PRINT '(f1,f2,...,fn)',e1,e2,...,en