MEMVAR UPDATE()

From Lianjapedia
Jump to: navigation, search

PURPOSE

Update a memory variable

SYNONYM

api_memvar_update()

SYNOPSIS

#include "lianja_api.h"
 
int	MEMVAR_UPDATE(name, type, width, decimal, string, number, logical, date)
 
<input parameters>
char		*name;		/* Address of a buffer containing the memory variable name	*/
char		type;			/* Memory variable type							*/
int		width;		/* Memory variable width						*/
int		decimal;		/* Number of decimal places						*/
char		string;		/* Address of a buffer containing character string			*/
double		*number;		/* Numeric value								*/
char		logical;		/* Logical value								*/
unsigned long	date;		/* date								*/
DATETIME	datetime;		/* datetime							*/
CURRENCY	currency;		/* currency								*/
 
<output parameters>
none

DESCRIPTION

The MEMVAR_UPDATE() function will update a specified memory variable.

Lianja will only recognize the first 32 characters on a memory name as being unique. The memory variable names are not case sensitive and must have been previously defined before updating, or the MEMVAR_UPDATE() function will return a value of -1.

Memory variables can be updated with different data types than they are currently defined. The variable type parameter specifies both the data type and which input parameter value will be used to update the memory variable.

The width parameter is used to specify length of the memory variable. A decimal place can be specified for a number, but should be 0 for other data types.

A memory variable can be defined as any one of the following.

TYPE OUTPUT WIDTH DESCRIPTION
C string 1-8192 Address of a buffer containing a character string
D date 8 Unsigned long representing a Lianja date
L logical 1 Character of either 'T' for true or 'F' for false
N number 1-16 A value stored in a double
T info_datetime sizeof(DATETIME) RCT_DATETIME_DEF structure
Y info_currency sizeof(CURRENCY) RCT_CURRENCY_DEF structure

EXAMPLE

The following example defines six memory variables and then stores the specified values to each variable.

#include "dbapi.h"
 
dbapi_store()
{
	int			rc;
	double			numeric;
	char			string[8];
	char			logical;
	unsigned long		date;
	DATETIME		datetime;
	CURRENCY		currency;
 
	strcpy(string, "Tuesday");
	date = DATE_CTOD(DATE_DATE());
	logical = 'T';
	numeric = 23.5;
	datetime = DATE_STOT(DATE_DATETIME());
	currency = CURR_STOY("6474.99");
 
	COMMAND("release all");
	MEMVAR_DEFINE( "character", API_PRIVATE );
	MEMVAR_DEFINE( "number", API_PRIVATE );
	MEMVAR_DEFINE( "logical", API_PRIVATE );
	MEMVAR_DEFINE( "date", API_PRIVATE );
	MEMVAR_DEFINE( "datetime", API_PRIVATE );
	MEMVAR_DEFINE( "currency", API_PRIVATE );
 
	rc = MEMVAR_UPDATE( "character", 'C', 7, 0, 
		string, &numeric, logical, date, datetime, currency);
	rc = MEMVAR_UPDATE( "number", 'N', 10, 2, 
		string, &numeric, logical, date, datetime, currency);
	rc = MEMVAR_UPDATE( "logical", 'L', 1, 0, 
		string, &numeric, logical, date, datetime, currency);
	rc = MEMVAR_UPDATE( "date", 'D', 8, 0, 
		string, &numeric, logical, date, datetime, currency);
	rc = MEMVAR_UPDATE( "datetime", 'T', sizeof(DATETIME), 0, 
		string, &numeric, logical, date, datetime, currency);
	rc = MEMVAR_UPDATE( "currency", 'Y', sizeof(CURRENCY), 0, 
		string, &numeric, logical, date, datetime, currency);
 
}

SEE ALSO

ARRAY_UPDATE(), MEMVAR_DEFINE(), MEMVAR_LOOKUP()