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.

PROCEDURES AND FUNCTIONS<br />

label section<br />

declares local labels.<br />

constant section<br />

defines local constant identifiers.<br />

type section<br />

defines local types.<br />

variable section<br />

declares local variables.<br />

procedure-and-function section<br />

statement<br />

declares local procedures and functions.<br />

specifies an action to be performed by the function. A function<br />

can contain any of the statements oescribed in Chapter 5. A<br />

function must contain a statement that assigns a value to the<br />

function ioentifier (for every potential path through the code).<br />

If it does not, the value of the function could be undefined.<br />

A function consists of a heading and a block. The formal parameter<br />

list in the function heading is identical in format to the list in the<br />

procedure heading. The function block is similar in structure and<br />

contents to the main program, with the following exceptions:<br />

• The function cannot contain a value initialization section .<br />

• The function block ends with END followed by a semicolon (;),<br />

rather than a period (.) as in the main program. The<br />

function does not have a block if it is a forward<br />

declaration, or if it is defined externally (EXTERN(AL) or<br />

FORTRAN) •<br />

You must declare all variables that are local to the function, but you<br />

should not redeclare a variable, type, or constant with the same name<br />

as a formal parameter or the function identifier.<br />

Each function must include a statement or statements that assigns a<br />

value of the result type to the function name. The last value that is<br />

assigned to the function name is returned to the calling program unit.<br />

To use the value, include a function call in the calling unit. Unlike<br />

a procedure call, a function call is not a statement. It simply<br />

represents a value of the function's resuJt type.<br />

6-33

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

Saved successfully!

Ooh no, something went wrong!