[fpc-pascal] Verify if string is a valid number

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Sun Nov 23 17:18:31 CET 2008


Hello,

I would like to verify if a string is a valid number, as in StrToInt
will work when applied to it. The obvious way is making a try
statement:

      try
        StrToInt(TokenStr);
        AdicionarToken(tNumeroLiteral, TokenStr);
      except
        AdicionarToken(tId, TokenStr);
      end;

but I don't like this solution, because a lot of exceptions will be
caused by normal execution of my program, which will disturb debugging
it ...

It's easy to build such a routine, but I was just thinking that maybe
there is one already somewhere in the RTL or FCL ... anyone know?

thanks,
-- 
Felipe Monteiro de Carvalho



More information about the fpc-pascal mailing list