User Tools

Site Tools


syntax:functions:asnumber

AsNumber(expression)

Category: Special function


Description

This function converts expression to a number.


Use cases

This is useful when you wish to validate the contents of a field or retrieve the number value of a field.


Arguments

ArgumentTypeDescription
expressionNumber, Text, BooleanThe value or result of an expression to be converted into a number value.

Return value type: Number


Remarks

  • Text should have only digits and one decimal point.
  • Boolean is converted into -1 (TRUE) or 0 (FALSE).
  • Number remains itself.
  • Everything else returns error.


Examples

asnumber( '123.45' )  //Returns 123.45
asnumber( 543.21 )  //Returns 543.21
asnumber( 1 > 2 )  //Returns 0  (FALSE result of an expression.)
asnumber( 'text' )  //Returns '#Can't convert to number'


See also

syntax/functions/asnumber.txt · Last modified: 2021/09/12 12:13 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki