Alternative Entry Name: RAW.WR
B: status = write( [unit,] buffer [, sector [, nwds] ] );
C: int write( [FILE *unit,] void *buffer, [int sector[, int nwds]]);
WRITE performs binary I/O on random or sequential disk files or tapes which have been opened by a call to OPEN.
If WRITE gets an eof status on a file, it attempts to grow the file enough to hold the data, provided that the write operation was exactly at the end of the file. If the grow is successful, the remainder of the write will be reissued. If the grow fails, WRITE will not make a second attempt at growing the file.
For a random disk file, "nwds" may be any non-zero value. However, if it is not a multiple of 64 when writing, the hardware will fill the remainder of the last sector with zeroes. The file pointer will be advanced (words+63)/64 sectors (where "words" is the number of words transfered, normally "nwds").
For a sequential disk file, "nwds" would normally be a non-zero multiple of 320. It must be less than or equal to 20160 (63 llinks). The file pointer will be advanced by (words+319)/320 llinks (where "words" is the number of words written, normally "nwds"). If "nwds" is not a multiple of 320 when writing, the hardware will fill the last sector with zeroes, and the remaining sectors of the last llink will be left untouched.
For a tape, "nwds" must be a non-zero value.
If a write encounters an EOF, and the file grow is unsuccessful, an EOF error will be raised.
When "status" is negative indicating an error was raised, and the file was opened with the "e" option, the A-register will contain the number of words transfered before the error. B users can retrieve this with a call to .NULL; C users can define the functions as returning a two-word struct.
When "unit" is in an error state, any WRITE is presumed to be an error recovery action such as rewriting a new header block, and so the error state is cleared before the I/O is attempted.
Copyright © 1993,1997 Thinkage Ltd.