[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
PRED Return the Predecessor of Number pp 141
Syntax: Pred (Scalar) ;
Type: Data type
Form: Function, procedure, declaration
Purpose: Returns the preceeding value of an ordinal type.
Notes: Pred of the first value of an ordinal type is undefined.
{$R-} strict range checking is off (default) then Pred will
wrap around to zero minus one. Type Byte wraps to 255 and type
Integer wraps to -1 ($FFFE).
----------------------------------------------------------------------------
Usage:
TYPE
Rainbo = (Red,Orange,Yellow,Green,Blue,Indigo,Violet) ;
CONST
Index : Byte = 4 ;
Colors : Array [0..6] of String [3] =
('Red','Org','Yel','Grn','Blu','Ind','Vio');
VAR
Bands : Rainbo ; { Bands is type Rainbo }
ChrVar : Char ; { Character variable }
BytVar : Byte ; { Byte variable }
IntVar : Integer ; { Integer variable }
StrVar : String [3] ; { String variable }
BEGIN
BytVar := Pred (0) ; { BytVar = 255 }
IntVar := Pred (0) ; { IntVar = -1 or $FFFE }
ChrVar := Pred ('Z') ; { ChrVar = Y }
Index := Pred (Ord(Yellow)) ; { Set index to 1 }
Bands := Pred (Orange) ; { Bands = Red }
{$R+} ; { Strict range checking on }
Bands := Pred (Red) ; { Undefined, gives R/T Err 91 }
StrVar := Colors [Pred (Index)] ; { Red }
END.
See Also:
Ord
Succ
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson