[Overview][Constants][Types][Classes][Procedures and functions][Variables] |
Calculate numerical value of a string.
Source position: system.fpd line 49
procedure Val( |
const S: String; |
var V; |
var Code: Word |
); |
Valconverts the value represented in the string Sto a numerical value, and stores this value in the variable V, which can be of type Longint, Realand Byte. If the conversion isn't succesfull, then the parameter Codecontains the index of the character in Swhich prevented the conversion. The string Sis allowed to contain spaces in the beginning. The string Scan contain a number in decimal, hexadecimal, binary or octal format, as described in the language reference.
If the conversion doesn't succeed, the value of Codeindicates the position where the conversion went wrong.
|
Convert a numerical value to a string. |
Program Example74; { Program to demonstrate the Val function. } Var I, Code : Integer; begin Val (ParamStr (1),I,Code); If Code<>0 then Writeln ('Error at position ',code,' : ',Paramstr(1)[Code]) else Writeln ('Value : ',I); end.