Difference between revisions of "EXPRESSION()"
From Lianjapedia
Barrymavin (Talk | contribs) |
Barrymavin (Talk | contribs) |
||
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 */ |
Revision as of 06:46, 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 */ 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 "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); } }