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 |
// Full Unit code. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses // The System unit does not need to be defined SysUtils, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); 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
ShowMessage('High(TChar) = '+IntToStr(Ord(High(TChar))));
ShowMessage('High(myChar) = '+IntToStr(Ord(High(myChar))));
ShowMessage('High(TArray) = '+IntToStr(High(TArray)));
ShowMessage('High(myArray) = '+IntToStr(High(myArray)));
ShowMessage('High(TEnum) = '+IntToStr(Ord(High(TEnum))));
ShowMessage('High(myEnum) = '+IntToStr(Ord(High(myEnum))));
ShowMessage('High(TShort) = '+IntToStr(Ord(High(TShort))));
ShowMessage('High(myShort) = '+IntToStr(Ord(High(myShort))));
end; end.
|
Hide 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
|
|