Name

Low Function

Syntax

function Low(Type or variable): Ordinal type;

Description

The Low function returns the smallest value of an enumerated type, the lower bound of an array index, or the same information for a variable of ordinal or array type.

Low is built into the compiler and is not a real function.

Tips and Tricks

  • In a for loop, subrange type declaration, or any other situation where you use the limits of an ordinal or array type, always use the Low function instead of referring explicitly to the low ordinal value. A future version of your code might change 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 the Low function.

  • Calling Low for a ShortString returns zero, which is the index of the length byte. You cannot call Low for an AnsiString or WideString, so use 1 because long strings always have an origin of 1.

  • Low for an open array parameter is always zero, regardless of the type or range of the actual array argument.

Example

See the High function for an example.

See Also

Dec Procedure, High Function, Inc Procedure, Length Function, Pred Function, Succ Function

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.