Difference between revisions of "ARRAY UPDATE()"

From Recital Documentation Wiki
Jump to: navigation, search
(SYNOPSIS)
(SYNOPSIS)
 
(4 intermediate revisions by one user not shown)
Line 14: Line 14:
  
 
<input parameters>
 
<input parameters>
char *arrayname; /* Address of a buffer containing the name of a Recital array */
+
char                       *arrayname; /* Address of a buffer containing the name of a Recital array */
int                          element; /* Element number */
+
int                          element; /* Element number                         */
char type; /* Type of field */
+
char                       type; /* Type of field */
int         width; /* Display width */
+
int                           width; /* Display width */
int         decimal; /* Display # decimals */
+
int                           decimal; /* Display # decimals */
char string; /* Address of a buffer containing a character string */
+
char                       string; /* Address of a buffer containing a character string */
double *number; /* Number */
+
double                   *number; /* Number */
char logical; /* Logical */
+
char                       logical; /* Logical */
unsigned long date; /* Recital date */
+
unsigned long     date; /* Recital date */
DATETIME datetime; /* Recital datetime */
+
DATETIME             datetime; /* Recital datetime */
CURRENCY currency; /* Recital currency */
+
CURRENCY           currency; /* Recital currency */
  
 
<output parameters>
 
<output parameters>
Line 122: Line 122:
  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
[[Category:SDK]]
+
[[Category:SDK]]</pre>

Latest revision as of 12:13, 30 March 2009

PURPOSE

Update the value in a Recital array


SYNONYM

api_array_update()


SYNOPSIS

#include "dbapi.h"
 
int	ARRAY_UPDATE(arrayname, element, type, width, decimal, string, number, logical, date, datetime, currency)
 
<input parameters>
char                        *arrayname;	/* Address of a buffer containing the name of a Recital array	*/
int                           element;		/* Element number							                        */
char                        type;		/* Type of field								*/
int                           width;		/* Display width								*/
int                           decimal;		/* Display # decimals							*/
char                        string;		/* Address of a buffer containing a character string		*/
double                    *number;	/* Number									*/
char                        logical;		/* Logical									*/
unsigned long      date;		/* Recital date								*/
DATETIME             datetime;	/* Recital datetime							*/
CURRENCY            currency;	/* Recital currency								*/
 
<output parameters>
none

DESCRIPTION

The ARRAY_UPDATE() function will update the specified element in the Recital array. The name and element number are used to specify the array element to update

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

NOTE: Recital array elements start at 1 and not 0 as in 'C'.

Array elements can be updated with data of a different type to their current value. 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 array element. A decimal place can be specified for a number, but should be 0 for other data types.

An array element can be defined as any one of the following.


TYPE OUTPUT WIDTH DESCRIPTION
C info_character 1 - 8192 address of a buffer containing a character string
D info_date 8 unsigned long representing a Recital Date
L info_logical 1 character of either 'T' for true or 'F' for false
N info_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 will define a six element array and update each array element with the specified values.

#include "dbapi.h"
 
dbapi_array_update()
{
    int			rc;
    double		numeric;
    char			string[8];
    char			logical;
    unsigned long	date;
    DATETIME		datetime;
    CURRENCY		currency;
 
    strcpy (string, "Recital");
    date = DATE_CTOD(DATE_DATE());
    logical = 'T';
    numeric = 23.5;
    memcpy(&datetime, DATE_STOT(DATE_DATETIME()), sizeof(DATETIME));
    memcpy(&currency, CURR_STOY("364.984"), sizeof(CURRENCY));
 
    COMMAND("release all");
    ARRAY_DEFINE("memvar", API_PUBLIC, 6,1);
 
    rc = ARRAY_UPDATE("memvar",1, 'C',7,0,
       string, numeric,
       logical, date, 
       datetime, currency);
    rc = ARRAY_UPDATE("memvar",2, 'N',10,2,
       string, numeric,
       logical, date, 
       datetime, currency);
    rc = ARRAY_UPDATE("memvar",3, 'L',1,0,
       string, numeric,
       logical, date, 
       datetime, currency);
    rc = ARRAY_UPDATE("memvar",4, 'D',8,0,
       string, numeric,
       logical, date, 
       datetime, currency);
    rc = ARRAY_UPDATE("memvar",5,'T',sizeof(DATETIME),0,
       string, numeric,
       logical, date, 
       datetime, currency);
    rc = ARRAY_UPDATE("memvar",6, 'Y',sizeof(CURRENCY),4,
       string, numeric,
       logical, date, 
       datetime, currency);
 
    _retl( (rc ==0) ? 1 : 0 );
}


SEE ALSO

_parinfa(), ALENGTH(), ISARRAY(), ARRAY_ALEN(), ARRAY_DEFINE(), ARRAY_LOOKUP()</pre>