Download PASCAL·SO USER`S GUIDE

Transcript
PASCAL-SO
Predeclared Procedures
•
pwroften(x): real
Returns 10 raised to the xth power, where x
O<=x<=38.
IS
an integer such that
Predicates
odd(x): boolean
Returns true if x is an odd integer, otherwise returns false; x must be of type
integer.
Transfer Functions
ord(x): integer
•
•
Returns the ordinal number of the value of x in the set defined by the type
of x. Note that x must be of a scalar type. See figure 3-5 for an example.
chr(x): char
Returns the character whose ordinal number is the value of x, if it exists; x
must be of integer type. See figure 3-5 for an example.
Miscellaneous Routines
succ(x): <type of x>
Returns the successor value of x, if it exists; x must be of a scalar or
suqrange type.
pred(x): <type of x>
•
Returns the predecessor value of x, if it exists; x must be of a scalar or
subrange type.
This program illustrates the use of
~he
predeclared procedures
ord and chr:
}
program threeS;
type
colors =
(red,green,yellow,blue);
beg in
writeln (ord (red): 3,ord (green): 3,ord (yellow): 3,ord (blue): 3);
l
writeln(chr(ord('A')));
end.
(3-5)
Executing this program will result in the following output:
•
o
1
2
3
A
Figure 3-5. Examples of Predeclared Procedures ord and chr
3-7