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.

<strong>PASCAL</strong> DATA TYPES<br />

Example 3<br />

F I 1...[<br />

TY'ial<br />

Datf:'~<br />

OF RECOf~D<br />

INTEGER;<br />

RECOF~D<br />

Month: (Jan, Feb, Mar, Apr, Mas, Jun,<br />

Jul, Aug, Sep, Oct, Nov, Dec);<br />

D a ~:1 : 1.. 3 l ~<br />

Y€·~ar : INTEGER<br />

END;<br />

Temp, Pressure : INTEGER;<br />

Yield, Purits : REAl...<br />

END;<br />

The VAR Declaration specifies a file of records. To access the fields<br />

of the record components, you specify ResultsA.Trial,<br />

ResultsA.Date.Month, and so on.<br />

2.3.4.1 Internal and External Files - A file that is local to a<br />

program or subprogram is called an internal file. You can use an<br />

internal file only within the scope of the program or subprogram in<br />

which it is declared. The system retains an internal file only during<br />

execution of the declaring program or subprogram. After execution the<br />

file is no longer accessible. The system creates a new file variable<br />

with the same name the next time it executes the declaring unit. The<br />

contents of the old file are not available. Internal files are not<br />

specified in the program heading. Only internal files can be<br />

components of structured types.<br />

An external file exists outside the scope of the program in which it<br />

is declared. An external file can be created by the current <strong>PASCAL</strong><br />

program, another <strong>PASCAL</strong> program, or a program written in another<br />

language. The system retains the contents of external file variables<br />

after the execution of the program. You must specify the names of<br />

external file variables in the program heading. External files cannot<br />

be part of a structured type.<br />

2.3.4.2 Text Files - A text file is a file with components of type<br />

CHAR. <strong>PASCAL</strong> defines a file type called TEXT. To declare a text<br />

file, specify a variable of type TEXT, for example:<br />

VAR Poem<br />

TEXT;<br />

The text file variable POEM is a file of characters. Text files are<br />

divided into lines. Each line ends with a line-separator character.<br />

You cannot use this character directly, but you can refer to it<br />

indirectly through the predeclared procedures READLN and WRITELN and<br />

the predeclared function EOLN.<br />

The pred~clared file variables INPUT and OUTPUT are files of type<br />

TEXT. These files are the defaults for all the predeclared text file<br />

procedures described in Chapter 7. Note that TEXT is not equivalent<br />

to FILE OF CHAR.<br />

Example<br />

VAR Guide, <strong>Manual</strong>:<br />

TEXT;<br />

This example declares the Variables Guide and <strong>Manual</strong> as text files.<br />

2-25

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

Saved successfully!

Ooh no, something went wrong!