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

Create successful ePaper yourself

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

INPUT AND OUTPUT<br />

READ does not read past EOLN if it is reading into a string type.<br />

Instead, READ continues to return blanks until the EOLN is explicitly<br />

passed by using READLN.<br />

If you call READ when the file is positioned at the end of a line, the<br />

file position moves to the beginning of the next line, unless it is c.<br />

string variable. Characters are then read into the specified starting<br />

variable. If this line is empty, the string is filled with spaces.<br />

Every text file ends with an end-of-line mark and an end-of-file mark.<br />

Therefore, the function EOF never becomes TRUE when you are reading<br />

strings with the READ procedure. To test EOF when reading strings,<br />

use the READLN procedure.<br />

Example I<br />

BEGIN<br />

READ (TemFY Ase~ Weisht);<br />

END;<br />

Assume that Temp, Age, and Weight are real variables, and you type<br />

the following values:<br />

in<br />

90.6 11.0 7~5+0<br />

The variable Temp takes on the value 98.6; Age<br />

11.0; and Weight takes on the value 75.0.<br />

type all three values on the same line.<br />

takes on the value<br />

Note that you need not<br />

Example 2<br />

TYPE Strins = PACKED ARRAY [1 •• <strong>20</strong>J OF CHAR;<br />

VAR Names TEXT;<br />

Pres~ Veep: Strins;<br />

BEGIN<br />

READ (Name!:., Pres, Veep);<br />

This program fragment declares and reads the file Names, which<br />

contains the following characters:<br />

John F. Kennedy<br />

Hubert H. Humphrey<br />

Richard M. Nixon<br />

Lyndon B. Johnson<br />

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

Saved successfully!

Ooh no, something went wrong!