Description |
The High function returns the highest allowed value of either a type or variable of that type.
It only applies to characters, arrays, enumerations and short strings.
For arrays, it returns the higest index.
|
|
Notes |
For multi-dimensional arrays, it returns the highest index of the first subarray (the left most definition of array range).
The size of an open array is given independent of the starting index of the array. It is the length of the array - 1.
|
|
Related commands |
Low |
|
Returns the lowest value of a type or variable |
|
|
|
Example code : High applied to character, array, enumeration and short strings |
type // Declare character, array and enumerated data types
TChar = char;
TArray = array [3..7] of Integer;
TEnum = (Mon=5, Tue, Wed, Thu, Fri, Sat, Sun);
TShort = shortstring;
var // Declare variables of the above data types
myChar : TChar;
myArray : TArray;
myEnum : TEnum;
myShort : TShort;
begin // Show the high values of the types and variables
WriteLn('High(TChar) = '+IntToStr(Ord(High(TChar))));
WriteLn('High(myChar) = '+IntToStr(Ord(High(myChar))));
WriteLn('High(TArray) = '+IntToStr(High(TArray)));
WriteLn('High(myArray) = '+IntToStr(High(myArray)));
WriteLn('High(TEnum) = '+IntToStr(Ord(High(TEnum))));
WriteLn('High(myEnum) = '+IntToStr(Ord(High(myEnum))));
WriteLn('High(TShort) = '+IntToStr(Ord(High(TShort))));
WriteLn('High(myShort) = '+IntToStr(Ord(High(myShort))));
end;
|
Show full unit code |
High(TChar) = 255
High(myChar) = 255
High(TArray) = 7
High(myArray) = 7
High(TEnum) = 11
High(myEnum) = 11
High(TShort) = 255
High(myShort) = 255
|
|