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 />

This example writes two components in the file Names.<br />

the <strong>20</strong>-character string constant 'Millard FiJlmore<br />

is the string variable Pres.<br />

Example 2<br />

The<br />

first is<br />

The second<br />

BEGIN<br />

WRITE (Num1:S:1,' and',Num2:S:1,' sum to',(NumltNum2)!6:1);<br />

END;<br />

If you specify an expression, <strong>PASCAL</strong> prints its value. For example,<br />

if Numl equals 71.1 and Num2 equals 29.9, this statement prints:<br />

71.1 and 29.9 sum to 101.0<br />

Note that each of the real numbers is preceded by a space.<br />

Example 3<br />

VAR Rainamts : FILE OF REAL;<br />

Avgrain,Maxrain~Minrain : REAL;<br />

BEGIN<br />

WRITE (Rainamts,Avgrain,Minrain,0.312,Maxrain);<br />

END;<br />

The file Rainamts contains real numbers indicating amounts of<br />

rainfall. The WRITE procedure writes the values of the variables<br />

Avgrain and Minrain into the file, followed by the real constant 0.312<br />

and the value of the variable Maxrain.<br />

7.15 THE WRITELN PROCEDURE<br />

The WRITELN procedure writes a line of data in a text file.<br />

Format<br />

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

where:<br />

file variable<br />

specifies the text file to be<br />

you omit the file variable,<br />

OUTPUT by default.<br />

written.<br />

<strong>PASCAL</strong><br />

If<br />

uses<br />

print list<br />

specifies the values to be output, separated<br />

by commas. The print list can specify<br />

constants, variable names, array elements,<br />

and record fields, with values of any scalar<br />

type. Output of strings is also permitted.<br />

Each value is output with a minimum field<br />

width.<br />

7-25

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

Saved successfully!

Ooh no, something went wrong!