Val function

Write here if you have problems with your Pascal source code

Moderator: Board moderators

Post Reply
ACoimbra
New poster
Posts: 14
Joined: Thu Apr 10, 2003 1:59 pm
Location: Coimbra, Portugal
Contact:

Val function

Post by ACoimbra » Sat Apr 26, 2003 5:05 pm

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?

fpnc
System administrator
Posts: 201
Joined: Sun Oct 07, 2001 2:00 am
Location: Valladolid, Spain

Post by fpnc » Sat Apr 26, 2003 10:50 pm

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.
Last edited by fpnc on Sun Apr 27, 2003 9:17 am, edited 1 time in total.
Best regards,

Fernando N

ACoimbra
New poster
Posts: 14
Joined: Thu Apr 10, 2003 1:59 pm
Location: Coimbra, Portugal
Contact:

Thnx

Post by ACoimbra » Sun Apr 27, 2003 12:37 am

Well, it works, thanks a lot

Post Reply

Return to “Pascal”