|
|
| |
 Net.Data for i5/OS
 | | |
| |
|
Here is the description of the function (this function is not yet in the Net.Data Reference manual).Available on V4R4 and subsequent releases. Ensure you have the latest Net.Data PTF.
DTW_EVAL
Purpose
Evaluate a mathematical expression.
Format
@DTW_EVAL(expression, result)
@DTW_rEVAL(expression)
Parameters
Table 1. DTW_EVAL Parameters
| Data Type
|
Parameter
|
Use
|
Description
|
| string |
expression
|
IN |
A variable or literal string representing a mathematical expression. |
| string |
result
|
OUT |
A variable that contains the result of evaluating the mathematical expression. |
Return Codes
Table 2. DTW_EVAL Return Codes
| Return Code
|
Explanation
|
| -1001 |
The server could not process a Net.Data request to allocate memory. |
| 1001 |
An input parameter contained a NULL value. |
| 1003 |
The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
| 1005 |
A parameter passed on a function call, required to be a string variable,was of a different variable type. |
| 1006 |
A literal string was passed on a function call for a parameter which was required to be an output parameter. |
| 4003 |
The mathematical expression is not valid. |
| 4004 |
An attempt was made to divide a number by zero. |
Usage Notes
- Valid operators are plus (+), minus (-), multiply (*), divide (/), power (**), and modulus (%). Any other characters, except for numbers and whitespace, are not allowed.
- Standard precedence rules will be used. Precedence order can be changed by use of parentheses.
- The result of mathematical operations is undefined if integers exceed allowed limits for signed 32-bit integers or floating-point numbers.
- The operand that follows a modulus (%) or power (**) operator must be an integer.
- The plus (+) and minus (-) operators can be unary operators, as in -3 or +10.
- Floats can be expressed in scientific notation.
Examples
-
%define calcsum = "($(n) * ($(n) + 1)) / 2"
@DTW_ASSIGN(n, "100")
@DTW_EVAL(calcsum, sum)
-
%define forumula1 = "(-$(b) + ($(b)**2 - 4*$(a)*$(c))) / (2*$(a))"
%define forumula2 = "(-$(b) - ($(b)**2 - 4*$(a)*$(c))) / (2*$(a))"
...
@DTW_ASSIGN(a, "1")
@DTW_ASSIGN(b, "2")
@DTW_ASSIGN(c, "1")
@DTW_EVAL(formula1, solution1)
@DTW_EVAL(formula2, solution2)
|
| |
|
|
|