声明: function Low ( type or variable ) : Ordinal type;
描述:Low函数返回一个类型或某个类型变量的最小允许值。它只应用于字符、数组、枚举和短字符串。对于数组,它返回数组的最小索引。
备注:对于多维数组,它返回第一个子数组(大多定义在数组范围最左边的那个)的最小索引。一个开放数组的最小元素被独立给予为数组的开始索引,通常是0。
{Low应用于字符、数组、枚举和短字符串} type // 声明字符、数组、枚举和短字符串 TChar = char; TArray = array [3..7] of Integer; TEnum = (Mon=5, Tue, Wed, Thu, Fri, Sat, Sun); TShort = shortstring; var // 声明上述类型的变量 myChar : TChar; myArray : TArray; myEnum : TEnum; myShort : TShort; begin // 显示类型和变量的最小值 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;
程序运行结果:
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