val(
VALUE
)

The val( function converts text into a number.


Parameters

This function has one parameter:

value – The text to be converted to a numeric value.


Description

The val( function converts text to a number, assuming of course that the text contains a numeric value. If the text contains a decimal point or exponent the resulting value is floating point, otherwise it is an integer. If the text doesn’t contain a recognizable number the result is an integer zero.

The val( function can also be used with a numeric parameter, in which case it simply passes the numeric value along. This can be handy when you don’t know for sure if a field or variable will contain text or a number.

Here are some examples of the val( function in operation:

val("72") ☞ 72
val("72.95") ☞ 72.95
val("2e3") ☞ 2000
val("  98  ") ☞ 98 // whitespace is ignored
val("abc") ☞ 0
val("234Z") ☞ 234 // non-digits at the end are ok
val("po234") ☞ 0 // but not at the beginning

If your text might contain non-digit characters you can use the striptonum( function to eliminate them.

val(striptonum("po234")) ☞ 234

If you are using floating point numbers use the stripchar( function like this.

val(stripchar("ZED 387.38","--09..")) ☞ 387.38

See Also


History

VersionStatusNotes
10.0No ChangeCarried over from Panorama 6.0