28.06.2013 Views

ISO Pascal reference manual

ISO Pascal reference manual

ISO Pascal reference manual

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.

*Execution error -- REWRITE required before write access<br />

This error is caused by an attempt to write to an input file. Before the data<br />

in an input file may be accessed the file must be made an output file by<br />

calling the procedure REWRITE.<br />

PROGRAM error(output);<br />

VAR f : text;<br />

BEGIN<br />

END.<br />

rewrite(f); (create it}<br />

writeln(f, this is a line'); (fill it}<br />

reset(f); (make it input}<br />

writeln(f, 'oops'); (wrong}<br />

writeln('Error not detected');<br />

*Execution error -- EOLN invalid at EOF<br />

This error is caused by calling the Boolean function EOLN when the file is<br />

at end-of-file (EOF). The function EOF(file) should usually be tested before<br />

EOLN to avoid this error.<br />

PROGRAM error(output)<br />

VAR f : text;<br />

BEGIN<br />

END.<br />

rewrite(f);<br />

writeln('one line');<br />

reset(f)<br />

readln; (nothing left in f now}<br />

IF EOLN(f) then writeln('end of line');<br />

writeln('Error not detected');<br />

*Execution error -- invalid number syntax<br />

This error is caused by an attempt to read a numerical value (integer or<br />

real) from a file if the input cannot be interpreted as a number. Note that<br />

the <strong>Pascal</strong> standard only permits spaces and end-of-lines to be skipped<br />

before a valid number is found. In particular a comma will not be skipped<br />

and will invoke this error.<br />

110 Pasca] Issue 1

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

Saved successfully!

Ooh no, something went wrong!