[Lazarus] How to check if a string is a valid floating-point number.

Santiago A. svaa at ciberpiula.net
Mon Nov 28 10:20:50 CET 2011

El vie, 25-11-2011 a las 14:34 +0100, Bart escribió:
> On 11/25/11, Santiago A. <svaa at ciberpiula.net <mailto:svaa at ciberpiula.net>> wrote:
> > El 25/11/2011 10:16, Kjow escribió:
> >
> > What about the standard pascal function  "val"
> >
> Doesn't Val() use a hardcoded period (.) as decimalseparator?
> The StrToFloat() family uses (Default)FormatSettings AFAIK.
> Bart

Yes, it does. val uses dot as decimal separator In fact, I am Spanish
and I use ',' as decimal separator, so I have such problem.

I remember I had used a similar function (in delphi). It deletes '.'
(just in case it has thousands separators) then replaces ',' for '.', 
then applies the 'val'. Probably it could be checked faster scanning
chars. But I found that function written and I didn't waste more time
optimizing it, anyway it is wide long much better than rising exceptions.

By the way, I don't have a delphi near to check it. Is tryStrTofloat a
fpc function or it is also a delphi function? If there is such function
in delphi, someone gave up searching help too soon.

Santiago A.
svaa at ciberpiula.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20111128/d1b21c89/attachment-0003.html>

More information about the Lazarus mailing list