Difference between revisions of "EXPRESSION()"
From Lianjapedia
Barrymavin (Talk | contribs) |
Yvonne.milne (Talk | contribs) m (Text replace - "lianjaapi.h" to "lianja_api.h") |
||
(5 intermediate revisions by one other user not shown) | |||
Line 3: | Line 3: | ||
==SYNONYM== | ==SYNONYM== | ||
− | + | LIANJA_EVALUATE() | |
==SYNOPSIS== | ==SYNOPSIS== | ||
<code lang="c"> | <code lang="c"> | ||
− | #include " | + | #include "lianja_api.h" |
int LIANJA_EVALUATE(result, exp) | int LIANJA_EVALUATE(result, exp) | ||
Line 15: | Line 15: | ||
<output parameters> | <output parameters> | ||
− | API_EXPRESSION result; /* Expression result | + | API_EXPRESSION result; /* Expression result */ |
</code> | </code> | ||
Line 26: | Line 26: | ||
struct API_EXPRESSION{ | struct API_EXPRESSION{ | ||
int errnum; /* error() number */ | int errnum; /* error() number */ | ||
− | char type; /* data type of result | + | char type; /* data type of result */ |
− | int width; /* width of result | + | int width; /* width of result */ |
− | int decimal; /* decimal places | + | int decimal; /* decimal places */ |
− | char *character; /* CHARACTER result | + | char *character; /* CHARACTER result */ |
− | double number; /* NUMERIC result | + | double number; /* NUMERIC result */ |
− | char logical; | + | char logical; /* LOGICAL result */ |
DATE date; /* DATE result */ | DATE date; /* DATE result */ | ||
DATETIME datetime; /* DATETIME result */ | DATETIME datetime; /* DATETIME result */ | ||
Line 70: | Line 70: | ||
<code lang="c"> | <code lang="c"> | ||
− | #include " | + | #include "lianja_api.h" |
lianjaapi_evaluate() | lianjaapi_evaluate() |
Latest revision as of 07:31, 11 April 2013
PURPOSE
Evaluate a Lianja expression
SYNONYM
LIANJA_EVALUATE()
SYNOPSIS
#include "lianja_api.h" int LIANJA_EVALUATE(result, exp) <input parameters> char *exp; /* Address of a buffer containing a valid Lianja expression */ <output parameters> API_EXPRESSION result; /* Expression result */
DESCRIPTION
The LIANJA_EVALUATE() function evaluates the specified Lianja expression and returns the result. This function returns 0 if successful, otherwise an error number.
The API Expression result structure is defined as follows:
struct API_EXPRESSION{ int errnum; /* error() number */ char type; /* data type of result */ int width; /* width of result */ int decimal; /* decimal places */ char *character; /* CHARACTER result */ double number; /* NUMERIC result */ char logical; /* LOGICAL result */ DATE date; /* DATE result */ DATETIME datetime; /* DATETIME result */ CURRENCY currency; /* CURRENCY result */ };
The data type result will be any one of the following:
RETURN VALUE | DESCRIPTION |
---|---|
C | character or memo data type |
N | numeric data type |
D | date data type |
L | logical data type |
T | datetime data type |
Y | currency data type |
EXAMPLE
The following example evaluates the specified expression and returns the result.
Example Lianja script:
use accounts m_result=evaluate("ord_value - paid_value") return
Example 'C' function:
#include "lianja_api.h" lianjaapi_evaluate() { struct API_EXPRESSION result; if (_parinfo(1) == API_CTYPE) { LIANJA_EVALUATE(&result, _parc(1)); if (result.errno != 0) { _retni(-1); } else { _retnd(result.number); } } else { _retni(-1); } }