Edit descriptors Tc, TLc and TRc provide a way of moving to a specific positions on the current input or output line. More importantly, they can move backward and forward. However, nX can only move forward. The general forms are
T6 moves to position 6. In the following, we shall use a blue blinking vertical bar to indicate the next position to be used.INTEGER :: a = 123, b = 456 WRITE(*,"(T6,I4,T2,I4)") a, b
Then, I4 is used to print the value of a. Since this value is 123, the printed result occupies positions 6, 7, 8 and 9, and the next position to be used is 10.1 1 2 ....5....0....5....0 T6
Now, T2 moves to position 2:1 1 2 ....5....0....5....0 T6 I4 123
I4 is used to print the value of b, which is 456. Thus, positions 2, 3, 4 and 5 will contain a space, 4, 5 and 6. The next available position is 6:1 1 2 ....5....0....5....0 T6 I4 123 T2 123
Now all variables have been printed and the result is1 1 2 ....5....0....5....0 T6 I4 123 T2 123 I4 456123
1 1 2 ....5....0....5....0 456 123
T10 moves to position 10:INTEGER :: a = 123, b = 456, c = 789 WRITE(*,"(T10,I3,TL9,I3,TR5,I3)") a, b, c
Then, I3 is used to print the value of a, which is 123. Thus, the output occupies positions 10 to 12 and the next position is 13:1 1 2 ....5....0....5....0 T10
TL9 moves backward 9 positions. Since the next position is 13, moving backward 9 positions is position 13-9=4:1 1 2 ....5....0....5....0 T10 I3 123
Then, I3 is used to print the value of b, which is 456. They occupy positions 4 to 6 and the next position becomes 7:1 1 2 ....5....0....5....0 T10 I3 123 TL9 123
TR5 moves forward five positions. Since the next position is 7, moving forward 5 positions is position 7+5=12:1 1 2 ....5....0....5....0 T10 I3 123 TL9 123 I3 456 123
Since position 12 already holds 3, we use a blue blinking 3 to remind you this fact. Then, I3 is used to print the value of c, which is 789. Thus, positions 12 to 14 will hold 7, 8 and 9 and the original value in position 12 (i.e., 3) is overwritten:1 1 2 ....5....0....5....0 T10 I3 123 TL9 123 I3 456 12
Now all variables are printed and the actual output is1 1 2 ....5....0....5....0 T10 I3 123 TL9 123 I3 456 12789
1 1 2 ....5....0....5....0 456 12789
Suppose we have the following input line:INTEGER :: a, b, c READ(*,"(T1,I5,T3,I5,T2,I5)") a, b, c
What are the values for a, b and c? In what follows, we shall use a blinking character to indicate the next position to be read.1 1 2 ....5....0....5....0 1234567890
The first edit descriptor is T1, which moves to position 1:
The next edit descriptor is I5, which is used to read the next five positions for a. Therefore, a receives 12345 and the next position is 6:1 1 2 ....5....0....5....0 1234567890 T1 234567890
Then, T3 moves back to position 3:1 1 2 ....5....0....5....0 1234567890 T1 1234567890 I5 123457890
The edit descriptor I5 reads the value in the next five positions to variable b. Therefore, b receives 34567 and the next position becomes 8:1 1 2 ....5....0....5....0 1234567890 T1 1234567890 I5 1234567890 T3 124567890
Then, T2 brings the position back to position 2:1 1 2 ....5....0....5....0 1234567890 T1 1234567890 I5 1234567890 T3 1234567890 I5 123456790
Finally, I5 takes the content in positions 2 to 6 for c. Thus, c receives 23456 and the next position is 7:1 1 2 ....5....0....5....0 1234567890 T1 1234567890 I5 1234567890 T3 1234567890 I5 1234567890 T2 134567890
Since all variables have received values, the activity of this READ terminates.1 1 2 ....5....0....5....0 1234567890 T1 1234567890 I5 1234567890 T3 1234567890 I5 1234567890 T2 1234567890 I5 123456890
Suppose we have the following input line:INTEGER :: a, b, c, d READ(*,"(2X,I3,TR7,I4,TL5,I1,T18,I2)") a, b, c, d
We shall determine the values in the variables.1 1 2 ....5....0....5....0 12345678901234567890
First, 2X skips the first two positions and the next available position is 3:
Then, I3 reads 345 into variable a and the next position is 6:1 1 2 ....5....0....5....0 12345678901234567890 2X 1245678901234567890
TR7 moves the next position to 6+7=13:1 1 2 ....5....0....5....0 12345678901234567890 2X 12345678901234567890 I3 1234578901234567890
Then, I4 reads 3456 into b and the next position is 17:1 1 2 ....5....0....5....0 12345678901234567890 2X 12345678901234567890 I3 12345678901234567890 TR7 1234567890124567890
TL5 moves backward 5 positions. Thus, the next position is 17-5=12:1 1 2 ....5....0....5....0 12345678901234567890 2X 12345678901234567890 I3 12345678901234567890 TR7 12345678901234567890 I4 1234567890123456890
I1 reads 2 into c and moves the next position to 13:1 1 2 ....5....0....5....0 12345678901234567890 2X 12345678901234567890 I3 12345678901234567890 TR7 12345678901234567890 I4 12345678901234567890 TL5 1234567890134567890
T18 moves to position 18:1 1 2 ....5....0....5....0 12345678901234567890 2X 12345678901234567890 I3 12345678901234567890 TR7 12345678901234567890 I4 12345678901234567890 TL5 12345678901234567890 I1 1234567890124567890
I2 reads 89 into d and moves the next position to 20:1 1 2 ....5....0....5....0 12345678901234567890 2X 12345678901234567890 I3 12345678901234567890 TR7 12345678901234567890 I4 12345678901234567890 TL5 12345678901234567890 I1 12345678901234567890 T18 1234567890123456790
Now every variable receives its value and the READ completes.1 1 2 ....5....0....5....0 12345678901234567890 2X 12345678901234567890 I3 12345678901234567890 TR7 12345678901234567890 I4 12345678901234567890 TL5 12345678901234567890 I1 12345678901234567890 T18 12345678901234567890 I2 1234567890123456789