[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
Retype Converts between Ordinal Types
Retype(OVal : <ordtype1>) : <ordtype2>; [TP]
Converts OVal to ordinal value of type <ordtype2>. Note that there is
no function named "Retype"; instead, you substitute <ordtype2> for the
function name. For example, if you want to convert Ch (of type Char)
to a Boolean value, the proper function call is Boolean(Ch). You can
use this with user-defined enumerated data types as well. Ord(OVal)
should be greater than or equal to Ord(lowest value in <ordtype2>) and
less than or equal to Ord(highest value in <ordtype2>).
OVal An ordinal value (constant, variable, function call,
or expression).
<ordtype1> Any ordinal type: Integer, Char, Boolean, or
enumerated data type.
<ordtype2> Same as <ordtype1>.
Limits: If range checking is enabled {$R+} and Ord(OVal) is
outside the range given above, runtime error 145 ($91)
occurs; otherwise, Ord(Retype(OVal)) = Ord(OVal).
-------------------------------- Example ---------------------------------
type
Days = (Sun,Mon,Tues,Wed,Thurs,Fri,Sat,Sun);
Colors = (Red,Orange,Green,Blue,Indigo,Violet);
var
Iota : Days;
Able : Colors;
Fred : Integer;
begin
Iota := Days(5); { Iota = Fri }
Able := Colors(0); { Able = Red }
Fred := Integer(Blue); { Fred = 3 }
Iota := Days(Able); { Iota = Sun }
end.
See Also:
Ord
Chr
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson