Alternate Entry Name: .RERED
B: reread( [unit] );
C: void reread( [FILE* unit] );
REREAD positions "unit" to read from the beginning of the current "line". REREAD defines a line as a stream of characters terminated by any of the characters "*n*f*r" (new-line, formfeed, carriage return); the terminating character is considered part of the line.
In TSS, at entry to MAIN, the terminal input unit (-5) is positioned at the end of the command line. As long as you have not tried to read from either unit 0 or -5, the code sequence
reread( -5 ); getstr( -5, command );
reads the command line into the vector "command". You could do this with the default input unit of zero, but this would fail if input had been redirected. In batch, the command line is NOT obtained from unit 0 or -5, so the sequence does not obtain the command line.
REREAD throws away all characters UNGETC has "ungot". For example, suppose that your input contains
Mary had a little lamb*n Its fleece was white as snow
and that GETCHAR has read in the first 'I' of the second line. Suppose too that UNGETC has been used to "unget" the 'I' and the '*n' at the end of the previous line. If you now call REREAD, REREAD throws away the '*n' and 'I', finds that it is in the midst of reading the second line, and therefore begins rereading with the 'I' of the second line. In other words, UNGETC cannot back REREAD up to a previous line.
Copyright © 1996, Thinkage Ltd.