For horizontal positioning along the print line, f77 supports the forms:
TRn, TLn, Tn, nT, T
where n is a strictly positive integer. The format specifier T can appear by itself, or be preceded or followed by a positive nonzero number.
This tab reads from the nth column or writes to the nth column.
This tab reads from the nth column to the left or writes to the nth column to the left.
This tab reads from the nth column to the right or writes to the nth column to the right.
This tab tabs to the nth tab stop for both read and write. If n is omitted, this tab uses n = 1 and tabs to the next tab stop.
This tab tabs to the next tab stop for both read and write. It is the same as the nTL with n omitted; it tabs to the next tab stop.
The rules and Restrictions for tabbing are:
Tabbing right beyond the end of an input logical record is an error.
Tabbing left beyond the beginning of an input logical record leaves the input pointer at the beginning of the record.
Nondestructive tabbing is implemented for both internal and external formatted I/O. Nondestructive tabbing means that tabbing left or right on output does not destroy previously written portions of a record.
Tabbing right on output causes unwritten portions of a record to be filled with blanks.
Tabbing left requires that the logical unit allows a seek. Therefore, it is not allowed in I/O to or from a terminal or pipe.
Likewise, nondestructive tabbing in either direction is possible only on a unit that can seek. Otherwise, tabbing right or spacing with the X edit specifier writes blanks on the output.
Tab stops are hard-coded every eight columns.
The nX edit specifier indicates that the transmission of the next character to or from a record is to occur at the position n characters forward from the current position.
On input, the nX edit specifier advances the record pointer by n positions, skipping n characters.
A position beyond the last character of the record can be specified if no characters are transmitted from such positions.
On output, the nX specifier writes n blanks.
The n defaults to 1.
Example: Input, Tn (absolute tabs):
demo% cat rtab.f CHARACTER C*2, S*2 OPEN( 1, FILE='mytab.data') DO I = 1, 2 READ( 1, 2 ) C, S 2 FORMAT( T5, A2, T1, A2 ) PRINT *, C, S END DO END demo%
demo% cat mytab.data defguvwx 12345678 demo%
demo% a.out uvde 5612 demo%
The above example first reads columns 5 and 6, then columns 1 and 2.
Example: Output Tn (absolute tabs); this program writes an output file:
demo% cat otab.f CHARACTER C*20 / "12345678901234567890" / OPEN( 1, FILE='mytab.rep') WRITE( 1, 2 ) C, ":", ":" 2 FORMAT( A20, T10, A1, T20, A1 ) END demo%
demo% cat mytab.rep 123456789:123456789: demo%
The above example writes 20 characters, then changes columns 10 and 20.
Example: Input, TRn and TL n (relative tabs)--the program reads:
demo% cat rtabi.f CHARACTER C, S, T OPEN( 1, FILE='mytab.data') DO I = 1, 2 READ( 1, 2 ) C, S, T 2 FORMAT( A1, TR5, A1, TL4, A1 ) PRINT *, C, S, T END DO END demo%
demo% cat mytab.data defguvwx 12345678 demo%
demo% a.out dwg 174 demo%
The above example reads column 1, then tabs right 5 to column 7, then tabs left 4 to column 4.
Example: Output TR n and TL n (relative tabs)--this program writes an output file:
demo% cat rtabo.f CHARACTER C*20 / "12345678901234567890" / OPEN( 1, FILE='rtabo.rep') WRITE( 1, 2 ) C, ":", ":" 2 FORMAT( A20, TL11, A1, TR9, A1 ) END demo%
The run shows nothing, but you can list the mytab.rep output file:
demo% cat rtabo.rep 123456789:123456789: demo%
The above program writes 20 characters, tabs left 11 to column 10, then tabs right 9 to column 20.