31.12.2013 Views

TOPS-20 PASCAL Language Manual - Bitsavers

TOPS-20 PASCAL Language Manual - Bitsavers

TOPS-20 PASCAL Language Manual - Bitsavers

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

INPUT AND OUTPUT<br />

You must call REWRITE before writing any file except the predeclared<br />

file OUTPUT. If you call REWRITE for the predeclared file INPUT or<br />

OUTPUT, a run-time error occurs.<br />

The REWRITE procedure sets the file to length zero and sets EOF to<br />

TRUE. You can then write new components into the file with the PUT,<br />

WRITE, or WRITELN procedure (WRITELN is defined only for text files).<br />

After the file is open, successive calls to REWRITE close and<br />

supersede the existing file; that is, they create new versions of the<br />

file.<br />

To update an existing file, you must<br />

file, specifying new values for<br />

upda te.<br />

copy its contents to another<br />

the components that you need to<br />

Example I<br />

BEGIN<br />

REWRITE (Storffis)~<br />

END;<br />

If the file variable Storms is already open, this statement enables<br />

writing and sets the file position to the beginning of the file. If<br />

Storms is not open, a new version is created with the same defaults as<br />

for the OPEN procedure.<br />

Example 2<br />

BEGIN<br />

OPEN (f~t:'sult~;" 'F'~:;:ISSUES+DAT' , OLD" ,FIXED);<br />

REWRITE (Hesults),<br />

END,<br />

The OPEN procedure sets defaults for the file variable Results, which<br />

is associated with the file ISSUES.DAT in directory PS:. The<br />

REWRITE procedure discards the current contents of the file Results<br />

and sets the file position at the beginning of the file. After<br />

execution of this statement, EOF(Results) is TRUE.<br />

7.14 THE WRITE PROCEDURE<br />

The WRITE procedure writes data into a file.<br />

Fo rma t<br />

WRITE [ file variable,] print list);<br />

7-21

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

Saved successfully!

Ooh no, something went wrong!