Syntax

number = VAL(text)

Arguments

number: numeric

text: text

Meaning

Returns the numeric value of a character string. You must always use this function when you want to calculate something using values from tags (whether those tags are FACS tags or taken directly from the currently open record), and when you want to numerically compare values, because in adapls, content from field tags is always of the text type.

Also note that sums like: tag1 = (val(tag2) + val(tag3)) really need the outer brackets around the whole addition to assign the numerical sum to tag1, otherwise val(tag2) will be assigned to tag1 first, turning it into a string ,and then val(tag3) will be added to tag1, making it a string addition.

Example 1

text = '1234.5'

number = VAL(text)

Result

number will be 1234.5 and can be used in calculations. text (a string which, in this situation, has 6 characters) cannot be used in calculations. Note that VAL(text) requires the decimal separator to be a dot, not a comma: a value with a comma cannot be converted to a numerical value.

Example 2

text = 'ABG14'

number = VAL(text)

Result

number will be 0.

Example 3

text = '1900 - 1950'

number = VAL(text)

Result

number will be 1900.

See also

INT

STR$