This section explains the functions that handle the numeric type.
The val() function extracts the numeric values from a string within an item reference.
The format of the val() function is illustrated below.
Point
The first instance of a string, in the format shown below, found in the string in the text expression is extracted as a numeric value.
Any commas (,) appearing in the integer part are ignored.
If a decimal point is specified, the decimal places will include all characters appearing from the decimal point onwards till the first instance of a non-numeric character.
Strings within the text expression that do not contain any numbers are treated as 0.
Note
If the integer part, excluding leading zeros, exceeds 18 digits, an error message is output and the input events are discarded (processing of subsequent input events continues).
See
Refer to "2.4.9 Item References" for details.
If specifying the number of decimal places, digits after the specified number of decimal places are truncated from the return value.
The range for decimal places is from -18 through 18.
If the number of decimal places argument is omitted, a value with up to a maximum of 18 decimal places is valid.
If the number of decimal places is a negative number, the digits to the left of the decimal point (integer part) are truncated.
Example
Consider the following value before truncation.
123456789012345678.1234567890123456789
Number of decimal places | Value after truncation |
---|---|
When omitted | 123456789012345678.123456789012345678 |
0 | 123456789012345678 |
1 | 123456789012345678.1 |
-1 | 123456789012345670 |
18 | 123456789012345678.123456789012345678 |
-18 | 0 |
A numeric value is returned if the function executes successfully.
Example
If $address is "3141 Fairview Park Drive, Falls Church":
val($address)
Only the numeric value 3141 is output.