Page 1 of 1

Val function

Posted: Sat Apr 26, 2003 5:05 pm
by ACoimbra
in http://www.freepascal.org/docs-html/ref ... 27400013.3 they say that val can convert hexadecimal numbers into integers, although my program doesn't work with that. Can anyone plz help me?

Posted: Sat Apr 26, 2003 10:50 pm
by fpnc
The string S can contain a number in decimal, hexadecimal, binary or octal format, as described in the language reference
Try this:

[pascal]var i,code:integer;
begin
val('$22',i,code);
if code<>0 then
writeln('Error at position ',code,' in $22')
else
writeln('Value: ',i);
end.[/pascal]

See http://www.freepascal.org/docs-html/ref ... 7-160001.5 for more information about this.

Thnx

Posted: Sun Apr 27, 2003 12:37 am
by ACoimbra
Well, it works, thanks a lot