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.

PASC~L<br />

STATEMENTS<br />

5.5 THE WITH STATEMENT<br />

The WITH statement provides abbreviated notation for references to<br />

fieJds of a record.<br />

Fo rma t<br />

WITH record variabJe [,record variable .•. ]<br />

DO statement;<br />

where:<br />

record variable specifies the name of the record variable to<br />

which the statement refers.<br />

The WITH statement allows you to refer to the fields<br />

directly instead of using the record.fieldname format.<br />

WITH statement opens the scope of the field identifiers<br />

can use them as you would use variable identifiers.<br />

of a record<br />

In effect, the<br />

so tha t you<br />

Specifying more than one record variable has the same effect as<br />

nesting WITH statements. The names must appear in the order of their<br />

declaration. Thus, the following two statements are equivalent:<br />

and<br />

WITH Cat, Dos DO<br />

Bills := Bills + Catvet + Do~vet;<br />

WITH Cat DO<br />

WITH Dos DO<br />

Bills := Bills + Catvet + Dosvet;<br />

Note that if the record Dog is nested within the record Cnt, you<br />

specify Cat before Dog.<br />

must<br />

Example 1<br />

RECORD<br />

Gross : REAL;<br />

Net : REAL;<br />

Bracket : REAL.;<br />

Itemized : BOOLEAN;<br />

Paid : REAL<br />

END;<br />

WITH TaNes DO<br />

IF Net < 10000.0 THEN Itemized := TRUE;<br />

This statement tests the value of the field Taxes.Net, and sets<br />

Taxes.Itemized to TRUE if Taxes.Net is less than 10000.0.<br />

5-12

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

Saved successfully!

Ooh no, something went wrong!