WWW.NNC.IR
Macro Reference
794
Vision System FH/FZ5 Series
User’s Manual (Z340)
Val
Converts a numeric character string to numeric value.
Format
Val(<string>)
Parameter
Return value
Returns the value as the double precision type real number.
Description
Converts the specified numeric character string in the <string> parameter to the numeric value.
Val is the inverse function of Str$. Str$ converts the specified numeric value to the numeric character string.
Specify a character string starting with either "+", "-", ".", or half-width numbers "0" to "9" to the <string>
parameter. If other characters than above is in the first character of the specified character string, 0 is
returned.
If there are characters that cannot be converted to numeric values in the specified alphanumeric character
string with the <string> parameter, characters from the beginning of the string to one character before the
inconvertible character are converted to a numeric value.
If an incorrect data type is specified for a parameter, a "Type mismatch" error will occur.
Even if a character string longer than 255 characters is specified for a character string parameter, an error will
not occur.
If a value is assigned to the return value variable or the variable is not used in an expression, a "Syntax error"
error will occur.
If the format is written incorrectly, such as writing the macro function name incorrectly, omitting a comma, or
omitting a half-width space, a "Syntax error" error will occur.
Usage Cautions
• None.
Example
Converts a numeric character string to numeric value.
The result is shown below.
Parameter
name
Data type Description
<string>
Character
string type
Numeric character string converted to numeric value
VALUE1# = Val("123.456")
VALUE2# = Val("-123.456")
VALUE3# = Val(".123")
VALUE4# = Val("-.456")
VALUE5# = Val("123"+"."+"456")
VALUE6# = Val("123+456")