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.