13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Here is a sample use of SEEK:SEEK CSTDRFILE, 13>;GET CSTDRFILE>;STOR_REC := STORFILEA;After this sequence, the variable STOR_REC will be set to the value of the14th file record in STORFILE.Here are the rules for using SEEK:o The file accessed by SEEK must be open.o If you try to use SEEK with a file variable of type TEXT, FILE OF CHAR,or INTERACTNE, or if the external file is a character device, SEEK doesnothing.o Two SEEK calls in a row may have unpredictable results. Use GET orPUT in between.o SEEK sets EOF to FALSE; the following GET or PUT sets it to its correctvalue .. If you call SEEK with a record number greater than the last record numberin the existing file, it goes through this process:1. SEEK first tries to expand the file by accessing the external file beyondits current end. If this is not possible (for example, because another diskfile is in the way), it causes an I/O error and sets IORESULT to 8 ("noroom on volume").2. If it is able to expand the file, SEEK numbers its record areas and triesto point to the record number specified in its call. Note that the recordareas beyond the current end-of-file have undefined contents. If there isstill not enough room for SEEK to sequence to the specified record, itcauses an I/O error and sets IORESULTto 8.3. Finally, SEEK compares the record size to the available room to makesure that an entire record could be written. If so, it exits; if not, it causesan I/O error and sets IORESULT to 8.By suspending I/O checking as described earlier, and then executingrepeated SEEK calls with incremented numbers and IORESULT checks,your program can determine how many records could be written to aspecific file.III-172Chapter 10: Input/Output

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!