March 2000
Intermediate to advanced
576 pages
18h 13m
English
Pred Function
function Pred(const Value): Ordinal type;The Pred function returns the predecessor of an
ordinal value, usually an enumerated value. That is, it returns the
enumerated value whose ordinal value is one less than
Value. Pred is not a real
function.
Dec, Pred, and subtraction by
one have similar performance, so choose the one that you find most
clear and easy to read.
Calling
Pred(Low(
SomeType
))
raises runtime error 4 (ERangeError). Without
overflow checking, though, Pred returns a value
with the desired ordinal value, even though that value is not valid
for the type.
type TDay =
(Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);
var
Day: TDay;
begin
...
Day := Pred(Day);
...| Dec Procedure, High Function, Inc Procedure, Low Function, Succ Function, $OverflowChecks Compiler Directive, $Q Compiler Directive |
Read now
Unlock full access