high()
The high()
function returns the highest possible and valid value of an enum, flag, integer or the high bound of an array type (the latter of which is often, but not always, equivalent to length-1
).
Syntax:
method high(expression): Integer;
int high(expression);
func high(_ expression) -> Integer
int high(expression);
For example:
type
Colors = enum(Red ,Blue, Yellow);
FCodes = flags(F2=2, F5=5, F8=8, F12=12);
var
i, iLo, iHi: Integer;
ai: array of Integer := [1,2,3,4,5];
color: Colors;
fcode: FCodes;
begin
iLo := low(ai); // 0
iHi := high(ai); // 4 (there are 5 values)
i := ai[high(ai)]; // 5
iLo := low(color); // 0
iHi := high(color); // 2 (there are 3 values)
iLo := low(fcode); // 0
iHi := high(fcode); // 3 (there are 4 values)
enum Colors { Red, Blue, Yellow }
int i, iLo, iHi: Integer;
int[] ai = [1,2,3,4,5];
Colors color
iLo = low(ai); // 0
iHi = high(ai); // 4 (there are 5 values)
i := ai[high(ai)]; // 5
iLo = low(color); // 0
iHi = high(color); // 2 (there are 3 values)
iLo = low(fcode); // 0
iHi = high(fcode); // 3 (there are 4 values)
enum Colors {
case Red, Blue, Yellow
}
var i, iLo, iHi: Int?
var ai = [1,2,3,4,5]
var color: Colors
iLo = low(ai) // 0
iHi = high(ai) // 4 (there are 5 values)
i = ai[high(ai)] // 5
iLo = low(color) // 0
iHi = high(color) // 2 (there are 3 values)
iLo = low(fcode) // 0
iHi = high(fcode) // 3 (there are 4 values)
enum Colors { Red, Blue, Yellow }
int i, iLo, iHi: Integer;
int[] ai = [1,2,3,4,5];
Colors color
iLo = low(ai); // 0
iHi = high(ai); // 4 (there are 5 values)
i := ai[high(ai)]; // 5
iLo = low(color); // 0
iHi = high(color); // 2 (there are 3 values)
iLo = low(fcode); // 0
iHi = high(fcode); // 3 (there are 4 values)