Difference between revisions of "EXPRESSION()"
From Lianjapedia
Yvonne.milne (Talk | contribs) m (1 revision) |
Barrymavin (Talk | contribs) |
||
Line 9: | Line 9: | ||
#include "lianjaapi.h" | #include "lianjaapi.h" | ||
− | int | + | int LIANJA_EVALUATE(result, exp) |
<input parameters> | <input parameters> | ||
Line 19: | Line 19: | ||
==DESCRIPTION== | ==DESCRIPTION== | ||
− | The | + | 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: | The API Expression result structure is defined as follows: | ||
Line 25: | Line 25: | ||
<code lang="c"> | <code lang="c"> | ||
struct API_EXPRESSION{ | struct API_EXPRESSION{ | ||
− | int | + | 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; | + | char *character; /* CHARACTER result */ |
− | double | + | double number; /* NUMERIC result */ |
char logical; /* LOGICAL result */ | char logical; /* LOGICAL result */ | ||
unsigned long date; /* DATE result */ | unsigned long date; /* DATE result */ | ||
DATETIME datetime; /* DATETIME result */ | DATETIME datetime; /* DATETIME result */ | ||
− | CURRENCY currency; /* CURRENCY result */ | + | CURRENCY currency; /* CURRENCY result */ |
}; | }; | ||
</code> | </code> | ||
Line 77: | Line 77: | ||
if (_parinfo(1) == API_CTYPE) { | if (_parinfo(1) == API_CTYPE) { | ||
− | + | LIANJA_EVALUATE(&result, _parc(1)); | |
if (result.errno != 0) { | if (result.errno != 0) { |
Revision as of 06:40, 11 April 2013
PURPOSE
Evaluate a Lianja expression
SYNONYM
api_expression()
SYNOPSIS
#include "lianjaapi.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 */ unsigned long 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 "lianjaapi.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); } }