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.3 CONSTANT DEFINITIONS<br />

The constant section defines identifiers to represent constant values.<br />

Fo rma t<br />

CONST constant name<br />

value; [constant name value; II<br />

where:<br />

constant name<br />

value<br />

specifies the identifier to be used as the<br />

name of the constant.<br />

specifies an jnteger, a real number, a<br />

string, a Boo]ean va]ue, or the name of<br />

another constant that is already defined.<br />

Note that the value assigned to a constant<br />

identifier cannot be an expression. String<br />

values must be enclosed in apostrophes.<br />

The use of constant identifiers generally makes a program easier to<br />

read, understand, and modify. If you need to change the value of a<br />

constant, you can simply modify the CONST declaration instead of<br />

changing each occurrence of the value in the program. This capability<br />

makes programs simpler to maintain and easier to transport.<br />

Example<br />

CON~)T Ra i n ~:: TRUE,<br />

Y to" a T' ~~ <strong>20</strong> O:L ,<br />

Pi ::: 3 .l4:1.!:j92?'<br />

C () ITlIT! a:;:: ',' p<br />

Countr~ = 'United States';<br />

Citizenship = Country;<br />

This CONST section defines six constants. The identifier Rain is<br />

equal to the Boolean value TRUE. The identifier Year represents an<br />

integer, and Pi represents the real number 3.1415927. The identifier<br />

Comma represents a character, and the identifier Country represents a<br />

string. Characters and strings must be enclosed in apostrophes in the<br />

CONST section. The identifier Citizenship represents the symbolic<br />

constant Country and thus repr~sents a character string. Note that,<br />

since Citizenship represents a symbolic value and not a string,<br />

apostrophes are not used.<br />

4-4

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

Saved successfully!

Ooh no, something went wrong!