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.

PROGRAM HEADING AND DECLARATION SECTION<br />

4.2 LABEL DECLARATIONS<br />

A label makes a statement accessible from a GOTO statement. The label<br />

section must list all the labels in the corresponding executable<br />

section.<br />

Format<br />

where:<br />

LABEL label [,label ... ]<br />

label specifies an unsigned integer. When you declare more<br />

than one label, you can specify the labels in any<br />

order.<br />

The label is an unsigned integer. Labels can be listed in any order<br />

if more than one label is defined. A label can precede any statement<br />

in the program, but can be accessed only by a GOTO statement. Within<br />

the program, a colon (:) must be placed between the label and the<br />

statement.<br />

The scope of a label is the block in which it is declared. Therefore,<br />

you can transfer control from one program unit to another program unit<br />

in which the former is nested, for example:<br />

PROGRAM Trial (INPUT,OUTPUT);<br />

LABEL 7~;<br />

PROCEDURE Max;<br />

LABEL 50;<br />

BEGIN<br />

50<br />

WRITELN ('Testins fairness of tosses');<br />

END;<br />

BEGIN<br />

GO TO 75;<br />

(*end of procedure Max*)<br />

75 WRITELN ('Not fair! A weighted coin!');<br />

END.<br />

The GOTO statement in the procedure Max transfers control to the main<br />

program statement that has the label 75. However, you cannot use a<br />

GOTO statement in the main program to transfer control into the<br />

procedure at label 50.<br />

Example<br />

LABEL 0, 6656, 778, 4352;<br />

The label section specifies four labels: 0, 6656, 778, and 4352.<br />

Note that the labels need not be specified in numeric order.<br />

4-3

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

Saved successfully!

Ooh no, something went wrong!