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 />

This program fragment reads characters into the packed array P. The<br />

procedure call to UNPACK assigns Prl] through PrIOl to the unpacked<br />

array elements AD] through ArlOl. Then, for each ca11 to<br />

PROCESS_ELEMENTS, one element of A is passea to the procedure.<br />

DATE AND TIME<br />

The predeclared procedures DATE and TIME assign the current date<br />

time to a string variable.<br />

and<br />

Fo rma t<br />

where:<br />

DATE(string);<br />

TIME(string) ;<br />

string specifies a variable of type PACKED ARRAyrl .. 11]<br />

CHAR.<br />

OF<br />

The folJowing example demonstrates the use of DATE and TIME:<br />

(* Declarations *)<br />

T ()da~3S __ Da te, CI..I l' rent .. _ Time<br />

(* Procedure calls *)<br />

PACKED ARRAY[1.+11J OF CHAR;<br />

DATE(Toda~5_Date)~<br />

TIME(Current_Time);<br />

These two calls return results in the following format:<br />

19-Jan--1980<br />

14:<strong>20</strong>:25<br />

The time is returned in 24-hour format. Thus, the time shown above is<br />

14 hours, <strong>20</strong> minutes, 25 seconds. In the DATE procedure, if the day<br />

of the month is a I-digit number, the leading zero does not appear in<br />

the result; that is, a space appears before the date string.<br />

6.1.2 Predeclared Functions<br />

<strong>PASCAL</strong> provides functions that compute arithmetic values, test certain<br />

Boolean conditions, transfer data from one type to another, and<br />

perform other miscellaneous calculations. Predeclared functions<br />

return a value as a resuJt. Table 6-2 summarizes the predeclared<br />

functions.<br />

Arithmetic functions perform mathematical computations. Parameters to<br />

these functions can be integer, real, single-precision, 01<br />

double-precision expressions. The arithmetic functions, except for<br />

the absolute and square root functions, return a real value when the<br />

parameter is an integer, single-precision, or real value. When the<br />

parameter is a double-precision expression, the result is a<br />

double-precision value. The absolute and square root functions return<br />

a value of the same type as the parameter.<br />

6-12

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

Saved successfully!

Ooh no, something went wrong!