Function to determine if a text string consists of numbers only (without any other symbols).
function IsStNumbers(st: string): boolean;
Parameter |
Type |
Value |
---|---|---|
st |
string |
source string. |
Returns true, if all string symbols are numbers from 0 to 9.
const
sOnlyNumbers = '3495760054';
sString = ' -784521az';
procedure TestString(s: string);
begin
if IsStNumbers(s) then mLogScript('string "' + s + '" - number', '')
else mLogScript('string "' + s + '" - not number', '');
end;
begin
TestString(sString);
TestString(sOnlyNumbers);
end.
[19:42:39] (Log "IsStNumbers"): string " -784521az" - not number
[19:42:39] (Log "IsStNumbers"): string "3495760054" - number
[19:42:39] (Run "IsStNumbers"): Script operation time: 3 ms
[19:42:39] (Run "IsStNumbers"): Script done successfully.