Special characters: Difference between revisions

m
(Added Kotlin)
Line 689:
 
===In FORMAT coding===
Within a FORMAT statement various single letters are used to indicate a format code, and these letters have no connection to any variables of that name outside the FORMAT statement. Not all compilers recognise all editing codes as there has been variation, extension, retraction, and standardisation in various directions. A list of such codes is producedprepared and there is the option of repeat counts, for single items or a group of items within brackets. Most codes select the form desired for a datum and may be constrained as to the type of the datum that is appropriate. The codes are single characters, often associated with integers that specify a width, thusso that I6 means an integer field of six characters. 3I6 means three such fields and 3(I6,I3) means three sets of a six and a three-digit field.
 
The basic idea is that the READ or WRITE statement has an I/O list which for output is a sequence of expressions (though usually just the name of a variable), while the input list may only be the names of variables, that are to receive the incoming data. Thus, the I/O list is worked through, in parallel with working through the items in the format list. Some format codes accept a datum and for output, describe what text is to go to the output buffer, while for input the format code describes what text from the input buffer is to be converted to a value to be placed in the waiting variable of the READ statement's input list. Other format codesitems specify actions to be taken before the next datum is dealt with and also adjust the working position along the text being read or written.
 
I9 Integer, width nine. I0 on output means a width sized to suit the numerical value.
L9 Logical, width nine but on output only <code>T</code> or <code>F</code> appears - see below.
F9.3 Floating-point, width nine with three decimal digits after its decimal point.
D9.3 Floating-point double-precision variables. Type clashes between datum and format code may be declared an error.
Q9.3 Floating-point quadruple precision, if available.
E9.3 Floating-point, exponential form, whereby one would appear as <code>0.100E+01</code> (ThereE10.3 iswould notallow enough space for athe sign)
A9 Character, width nine. Just <code>A</code> meansto transfer as many characters as the variable holds. For input, up to the end of the record.
B9 Any type. Transfers binary bits as stored in the variable. Not necessarily its numerical value in binary.
O9 In octal. For floating-point especially the bit pattern will not be that of the value in binary.
Z9 In hexadecimal.
9X Space over nine columns. Alas, 4X3 is not allowed for four advances of three. Only 12X will do.
1,220

edits