[fpc-pascal] Something like "Is a number"?

Florian Klaempfl F.Klaempfl at gmx.de
Sat Jul 9 11:51:48 CEST 2005


Thomas Zastrow wrote:

> John Coppens wrote:
> 
>> On Fri, 08 Jul 2005 16:39:05 +0200
>> Thomas Zastrow <chef at thomas-zastrow.de> wrote:
>>
>>  
>>
>>> Hello,
>>>
>>> I'm converting some strings with "strtoint" into integers. But
>>> sometimes the string can't be converted to a number. Is there a
>>> function which takes a string and tells me if it is possible or not to
>>> convert it into a number? Something like "IsANumber(string)"
>>>
>>>   
>>
>> You can use val(str, int/real, err)
>>
>> if err is 0, the string was converted to an integer or real (depending on
>> the type of int/real.
>>
>> John
>>  
>>
> Thank you, it's working!!!

You can also use TryStrToInt from the sysutils unit.




More information about the fpc-pascal mailing list