Converts an expression of any data type, with the exception of BLOB, CLOB, and RAW, to a DECIMAL value.
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. |