Difference between revisions of "EXPRESSION()"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
Line 28: Line 28:
 
<code lang="c">
 
<code lang="c">
 
struct API_EXPRESSION{
 
struct API_EXPRESSION{
     int errno; /* RECITAL error() number */
+
     int errno; /* RECITAL 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; /* LOGICAL result */
+
     char logical; /* LOGICAL result */
     unsigned long date; /* Recital DATE result */
+
     unsigned long date; /* Recital DATE result */
     DATETIME datetime; /* Recital DATETIME result */
+
     DATETIME datetime; /* Recital DATETIME result */
     CURRENCY currency; /* Recital CURRENCY result */
+
     CURRENCY currency; /* Recital CURRENCY result */
 
};
 
};
 
</code>
 
</code>

Latest revision as of 12:07, 30 March 2009

PURPOSE

Evaluate a Recital expression


SYNONYM

api_expression()


SYNOPSIS

#include "dbapi.h"
 
int	EXPRESSION(result, exp)
 
<input parameters>
char	*exp;			/* Address of a buffer containing a valid Recital command	*/
 
<output parameters>
API_EXPRESSION result;		/* Expression result							*/


DESCRIPTION

The FUNCTION() function evaluates the specified Recital expression and returns the result. This function returns 0 if successful, otherwise a Recital error number.

The API Expression result structure is defined as follows:

struct API_EXPRESSION{
    int			errno;		/* RECITAL 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;			/* Recital DATE result			*/
    DATETIME		datetime;		/* Recital DATETIME result		*/
    CURRENCY	currency;		/* Recital 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 Recital program:

use accounts
m_result=evaluate("ord_value - paid_value")
return

Example 'C' function:

#include "dbapi.h"
 
dbapi_evaluate()
{
	struct	API_EXPRESSION result;
 
	if (_parinfo(1) == API_CTYPE) {
		EXPRESSION(&result, _parc(1));
 
		if (result.errno != 0) {
			_retni(-1);
		} else {
			_retnd(result.number);
		}
	} else {
		_retni(-1);
	}
}


SEE ALSO

COMMAND()