Dec DataWindow expression function
Description
Converts the value of a string to a decimal.
Syntax
1 |
<span>Dec</span> ( <span>string</span> ) |
Argument |
Description |
---|---|
string |
The string you want returned as a decimal |
Return Values
Decimal. Returns the contents of string as
a decimal if it succeeds and 0 if string is
not a number.
Usage
The decimal datatype supports up to 28 digits.
You can also append the letter D in upper or lowercase to
identify a number as a decimal constant in DataWindow expressions. For example, 2.0d
and 123.456789012345678901D
are
treated as decimals.
Examples
This expression returns the string 24.3 as a decimal
datatype:
1 |
<span>Dec</span>("24.3") |
This expression for a computed field returns “Not
a valid score” if the string in the score column does not
contain a number. The expression checks whether the Dec function
returns 0, which means it failed to convert the value:
1 |
If (<span> Dec</span>(score) <> 0, score, "Not a valid score") |
This expression returns 0:
1 |
<span>Dec</span>("3ABC") <span></span> // 3ABC is not a number |
This validation rule checks that the value in the
column the user entered is greater than 1999.99:
1 |
<span>Dec</span>(GetText()) > 1999.99 |
This validation rule for the column named score insures
that score contains a string:
1 |
<span>Dec</span>(score) <> 0 |
See Also
-
Dec in the PowerScript
Reference