[fpc-devel] Addtions for strutils

Jonas Maebe jonas.maebe at elis.ugent.be
Sun Jan 22 11:33:14 CET 2006

On 22 Jan 2006, at 11:24, ik wrote:

>> val(x,code);
>> result:=(code=0)  and (posexset(['+','-'],x)=0)
>> would already do. (untested from memory)
> And why is that better ?

Because it reuses existing code (although the above could even be  
made shorter by using TryStrToInt or so). Reusing existing code is  
pretty much always better, because it improves maintainability,  
reduces the chance to bugs and keeps the code size smaller.

> I do a loop and see if I only have the valid
> chars or stop. What happen if I have a number with 20 or 50 chars
> based ? I only want to check if it contains a valid number chars, not
> to actually convert it to anything (no one promise you that you can
> convert it to any existed type!).

I really don't think this is something which is needed in an rtl unit.


More information about the fpc-devel mailing list