Function Val() Foundation
Converts a number in the form of a character string to a numeric value.
Val( <cNumber> ) --> nNumber
The return value of Val() is the numeric value represented in the character string <cNumber>.
The character function Val() converts a character string containing only digits or digits and a decimal point to its numeric equivalent. The character string <cNumber> is evaluated starting at the left. Leading blank spaces are ignored. The conversion ends when Val() hits a character which is not a digit or when a second decimal point appears.
When the number of decimal places for the display is fixed with the command SET FIXED ON, the function Val() returns a value which has the number of places after the decimal point set by SET DECIMALS. Places after the decimal point are rounded if necessary. When the setting SET FIXED is set to OFF, Val() returns a value with as many places after the decimal point as is included in <cNumber>.
The reverse functions to Val() are the functions Str() and Transform() which convert a numeric value to a character string.
// The example shows various results of the function Val()
PROCEDURE Main
SET DECIMALS TO 2
SET FIXED ON
? Val( "67.479" ) // result: 67.48
? Val(" 67.479") // result: 67.48
? Val( "67*479" ) // result: 67.00
? Val("X67*479" ) // result: 0.00
? Val( Time() ) // result: 16.00
? Val( DtoC(Date()) ) // result: 12.00
SET DECIMALS TO 10
SET FIXED OFF
? Val( "67.479" ) // result: 67.479
? Val(" 67.479") // result: 67.479
? Val( "67*479" ) // result: 67
? Val("X67*479" ) // result: 0
? Val( Time() ) // result: 16
? Val( DtoC(Date()) ) // result: 12
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.