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.

<strong>PASCAL</strong> D~TA<br />

TYPES<br />

2.3.4 File Types<br />

A file is a sequence of data components of the same type. The number<br />

of components in a file is not fixed; a file can be of any length.<br />

The file type definition specifies the type of the file components.<br />

Fo rma t<br />

TYPE identifier<br />

FILE OF component type<br />

where:<br />

component type specifies the type of the components of the<br />

file. The component type can be any scalar<br />

or structured type except a file type or an<br />

array or record type containing a file<br />

element or field.<br />

The arithmetic, relational, Boolean, and assignment operators do not<br />

work on file variables or structures containing file components. For<br />

example, you cannot assign one file variable to another file variable,<br />

nor can you initialize a file variable.<br />

Type compatibility for files applies only to file parameters. Two<br />

file parameters are compatible if their components are compatible and<br />

if both are packed or neither is packed. You can pass a file only as<br />

a VAR parameter.<br />

<strong>PASCAL</strong> automatically creates a buffer variable for each file variable<br />

you declare. The type of the buffer variable is the same as the type<br />

of the file components. To denote the buffer variable, specify the<br />

name of the associated file variable fo] lowed by a circumflex (~), for<br />

example:<br />

TYPE Scores = FILE OF INTEGER;<br />

VAR Math_Scores: Scores;<br />

<strong>PASCAL</strong> creates ~ath Scores~ as an integer buffer variable associated<br />

with the file Math Scores. The buffer variable takes on the value of<br />

the file at the cur~ent file position. The predeclared input and<br />

output procedures move the file position, thus changing the value of<br />

the buffer variable.<br />

Example I<br />

VAF, T ruthva 1. s FIL.E OF' BOOLEAN;<br />

This declaration specifies a file of Boolean values.<br />

variable for this file is denoted by Truthva]s~.<br />

Example 2<br />

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

Data .... Fi Ie :::: FILE or Names;<br />

VAH Accept .... L..ist" RejecL.List, Wait_List: Data_File;<br />

The<br />

buffer<br />

This example defines the array type Names and the file type DataFile,<br />

which contains a list of names. The VAR section specifies three file<br />

variables of type DataFile, with associated buffer variables<br />

Accept_List~, Reject_List~, and Wait List~.<br />

2-24

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

Saved successfully!

Ooh no, something went wrong!