Mega Code Archive

 
Categories / Delphi / Functions
 

Low - returns the lowest value of a type or variable system unit

function Low ( type or variable ) : Ordinal type; Description The Low function lowest 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 lowest array index. Notes For multi-dimensional arrays, it returns the lowest index of the first subarray (the left most definition of array range). The lowest element of an open array is given independent of the starting index of the array. It is always 0. Related commands High Returns the highest value of a type or variable Example code : Low 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 low values of the types and variables ShowMessage('Low(TChar) = '+IntToStr(Ord(Low(TChar)))); ShowMessage('Low(myChar) = '+IntToStr(Ord(Low(myChar)))); ShowMessage('Low(TArray) = '+IntToStr(Low(TArray))); ShowMessage('Low(myArray) = '+IntToStr(Low(myArray))); ShowMessage('High(myArray) = '+IntToStr(High(myArray))); ShowMessage('Low(TEnum) = '+IntToStr(Ord(Low(TEnum)))); ShowMessage('Low(myEnum) = '+IntToStr(Ord(Low(myEnum)))); ShowMessage('High(myEnum) = '+IntToStr(Ord(High(myEnum)))); ShowMessage('Low(TShort) = '+IntToStr(Ord(Low(TShort)))); ShowMessage('Low(myShort) = '+IntToStr(Ord(Low(myShort)))); end; Show full unit code Low(TChar) = 0 Low(myChar) = 0 Low(TArray) = 3 Low(myArray) = 3 Hig( myArray) = 7 Low(TEnum) = 5 Low(myEnum) = 5 Hig( myEnum) = 11 Low(TShort) = 0 Low(myShort) = 0