Release 10.1A: OpenEdge Development:
Progress 4GL Reference

> ## DECIMAL function

> Converts an expression of any data type 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 credit-limit 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 credit-limit. The DECIMAL function converts the value entered into a decimal value.

> r-decml.p
>     DEFINE VARIABLE new-max AS CHARACTER FORMAT "x(10)".

>     REPEAT:
>         PROMPT-FOR customer.cust-num WITH FRAME credit.
>         FIND customer USING cust-num.
>         DISPLAY cust-num name credit-limit 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 credit-limit = 5000.
>         ELSE IF new-max = "b" THEN credit-limit = 2000.
>         ELSE IF new-max > "0" AND new-max < "999,999.99" THEN
>              credit-limit = DECIMAL(new-max).
>         ELSE credit-limit = 1000.
>         DISPLAY credit-limit WITH FRAME credit.
>     END.

> #### See also

> INTEGER function, STRING function

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095