_Store( ) API Library Routine
Replaces the memory variable specified by loc with the value val.
int _Store(Locator FAR *loc, Value FAR *val)
Locator FAR *loc; /* Memory variable locator. */
Value FAR *val; /* Value to store. */
Remarks
Reference individual array elements by setting l_subs to the number of subscripts you specified and l_sub1 and l_sub2 to the actual subscripts. The first element of an array is numbered 1. If loc specifies an array and l_subs is 0, _Store( ) stores the value in val to all elements in the array.
_Store( ) returns 0 if it is successful. If it fails, _Store( ) returns a negative integer whose absolute value is a Visual FoxPro error number. If _Store( ) runs out of memory while storing to an array, some values of some array elements may have been set, and others may not have been.
For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.
Example
The following example converts to uppercase a string argument passed by reference.
Visual FoxPro Code
SET LIBRARY TO STORE
x = "abc"
= XUPPER(@x)
? x
C Code
#include <pro_ext.h>
void FAR Upper(ParamBlk FAR *parm)
{
char FAR *pString;
Value val;
int i;
//
// _Load() and _Store are the functions of interest for pass-by-reference.
//
_Load(&parm->p[0].loc, &val);
//
// FoxPro doesn't check the type of pass-by-reference arguments, so we do.
//
if (val.ev_type != 'C') {
_Error(9); // "Data type mismatch"
}
pString = _HandToPtr(val.ev_handle);
for (i = 0; i < val.ev_length; i++) {
if ('a' <= *pString && *pString <= 'z') {
*pString += ('A' - 'a');
}
pString++;
}
_Store(&parm->p[0].loc, &val);
//
// We need to free the handle that we created with _LOAD()
//
_FreeHand(val.ev_handle);
}
FoxInfo myFoxInfo[] = {
{"XUPPER", (FPFI) Upper, 1, "R"},
};
FoxTable _FoxTable = {
(FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};
See Also
_ALen( ) API Library Routine | _FindVar( ) API Library Routine | _Load( ) API Library Routine | _NameTableIndex( ) API Library Routine | _NewVar( ) API Library Routine | _ObjectRelease( ) API Library Routine