str_int/2
Same as the Visual Prolog predicate str_int(STRING,INTEGER):
str_int(STRING StringArg, INTEGER IntArg)
Flow patterns: (i, o), (o, i), (i, i)
Convert between strings and integers
Remarks:
(o,i) Binds StringArg to a string of decimal digits representing the value to which IntArg is bound.
(i,o) Binds IntArg to the internal (binary) equivalent of the decimal integer to which StringArg is bound.
(i,i) Succeeds if IntArg is bound to the internal (binary) representation of the decimal integer to which StringArg is bound.
A leading sign is optional, and leading and trailing spaces are ignored.
Fail:
The (i,o) and (i,i) flow versions will fail if StringArg does not compose a valid integer.
Errors: 1031 Arithmetic overflow.
The error is generated if StringArg composes an integer number but its value overruns the maximum or minimum value correctly representable by the INTEGER domain under the used platform.
Therefore, you must be careful using this predicate for checking data compatibility.
Examples:
str_int("123",INT)
INT=123
1 Solution
str_int(STR,123)
STR=123
1 Solution
str_int("123",123)
Yes
str_int(" -123 ",INT)
INT=-123
1 Solution
str_int(" -1x23 ",INT)
No Solution