IN - SOLVE

The IN - SOLVE statement will solve a simple arithmetic expression and place the result in a NUMBER variable. Only +, -, /, * operators, NUMBER values, and TEXT values can be used in a MATH-EXPRESSION. Other LDPL arithmetic functions, like CEIL and MODULO, are not supported by this statement and should be used as standalone statements. TEXT values will be implicitly converted to NUMBERs using the same algorithm as STORE - IN.

Spaces must be used to separate numbers, variables and operators.

As in actual arithmetic, * and / have higher precedence than + and - , while parens () can be used to group expressions.

Syntax:

IN <NUMBER-VAR> SOLVE <MATH-EXPRESSION>

Example:

IN myNumVariable SOLVE 1 + 1

Will set the value of myNumVariable to 2.

Area of Circle:

DATA:
Radius is NUMBER
Area is NUMBER
PROCEDURE:
DISPLAY "Enter Radius: "
ACCEPT Radius
IN Area SOLVE 3.14159 * (Radius * Radius)
DISPLAY "Area is: " Area CRLF

Outputs:

Enter Radius: 0.5
Area is: 0.7853975