Calculates the logarithm of an expression using a specified base and returns that logarithm as a DECIMAL value.
This procedure prompts the user for a base and a number, and then displays the log of the number. The VALIDATE option on the UPDATE statement ensures that the user enters a base value greater than 1 and a number greater than 0.
r-log.p
DEFINE VARIABLE base AS DECIMAL NO-UNDO FORMAT ">>>,>>>.9999".
DEFINE VARIABLE number AS DECIMAL NO-UNDO.
REPEAT:
UPDATE base VALIDATE(base > 1, "Base must be greater than 1").
REPEAT:
UPDATE number VALIDATE(number > 0, "Number must be positive").
DISPLAY number LOG(number, base) LABEL "LOG(NUMBER, BASE)".
END.
END.
|