Name
High Function
Syntax
function High(Type or variable):Ordinal type;
Description
The High function returns the largest value of an
enumerated type, the upper bound of an array index, or the same
information for a variable of ordinal or array type.
High is built into the compiler and is not a real
function.
Tips and Tricks
In a
forloop, subrange type declaration, or any other situation where you use the limits of an ordinal or array type, always use theHighfunction instead of referring explicitly to the high ordinal value. A future version of your code might extend the type, and you don’t want to scramble through all your code looking for explicit references to an enumerated literal that should really have been calls to theHighfunction.Calling
Highfor aShortStringreturns the highest index for the string type. You cannot callHighfor anAnsiStringorWideString.Highfor an open array parameter is always the length of the array minus one, regardless of the type or range of the actual array argument.
Example
// See the example of the asm keyword for the GetCpuId function. // Get the CPU identification, and write it to Output. procedure WriteCpuId; const CpuTypes: array[TCpuType] of string = ('Original', 'Overdrive', 'Dual', '?'); var ID: TCpuId; F: TCpuFeature; begin if not GetCpuId(ID) then WriteLn('No CPUID instruction') else begin WriteLn(ID.Vendor, ' ', CpuTypes[ID.CpuType]); WriteLn('Family: ', ID.Family); WriteLn('Model: ', ID.Model); WriteLn('Stepping: ', ID.Stepping); ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access