ABL Reference
ABL Syntax Reference : DECIMAL function

# DECIMAL function

Converts an expression of any data type, with the exception of BLOB, CLOB, and RAW, to a DECIMAL value.

## Syntax

 DECIMAL ( expression )
expression
If expression is a CHARACTER, then it must be valid for conversion into a number. (For example, 1.67 is valid but 1.x3 is not valid.) If expression is LOGICAL, then the result is 0 if expression is FALSE and 1 if expression is TRUE. If expression is a DATE, then the result is the number of days from 1/1/4713 B.C. to that date. If the value of expression is the Unknown value (?), then the result is also the Unknown value (?).

## Example

The example procedure lets the user enter new values for CreditLimit in a special form. If the user enters the letter a, the procedure uses the standard a credit of 5000; if the user enters b, the procedure uses a value of 2000; if the user presses RETURN, the procedure uses a value of 1000. Otherwise, the user can enter any value for CreditLimit. The DECIMAL function converts the value entered into a decimal value.
r-decml.p
 DEFINE VARIABLE new-max AS CHARACTER NO-UNDO FORMAT "x(10)".REPEAT:  PROMPT-FOR Customer.CustNum WITH FRAME credit.  FIND Customer USING Customer.CustNum.  DISPLAY Customer.CustNum Customer.Name Customer.CreditLimit     WITH FRAME credit DOWN.  DISPLAY "Enter one of:" SKIP(1)    "a = 5000" SKIP    "b = 2000" SKIP    "RETURN = 1000"    "A dollar value"    WITH FRAME vals COLUMN 60.  SET new-max WITH FRAME credit.       IF new-max = "a" THEN Customer.CreditLimit = 5000.  ELSE IF new-max = "b" THEN Customer.CreditLimit = 2000.  ELSE IF new-max > "0" AND new-max < "999,999.99" THEN    Customer.CreditLimit = DECIMAL(new-max).  ELSE Customer.CreditLimit = 1000.  DISPLAY Customer.CreditLimit WITH FRAME credit.END.