How to convert a number printed in a string into integer?
Thank you.
This is the procedure Val:
procedure Val(S; var V; var Code: Integer);
This procedure operates on integer and real numbers.
Parameters:
S
char sequence; for proper conversion, it has to contain only characters from the set +-,.0123456789
.V
The result of conversion, if conversion succeeds. If the result is going to be an Integer, then S can't contain ,
or .
.Code
Returns the position in S
of the character that interrupted the conversion, if conversion does not succeed.Use cases:
Var Value :Integer;
Val('1234', Value, Code); // Value = 1234, Code = 0
Val('1.234', Value, Code); // Value = 0, Code = 2
Val('abcd', Value, Code); // Value = 0, Code = 1