On Sun, 23 Nov 2008, Felipe Monteiro de Carvalho wrote:
> 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? If TryStrToInt(s,i) then Writeln('S has a valid number:',I); Or Val(S,I,C); If C=0 then Writeln('S has a valid number:',I); Michael. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal