_StrCpy( ) API Library Routine Example

The following example is passed a Visual FoxPro array of type Character. It then replaces the second element using _Store( ).

Before calling MYFUNC( ), the Visual FoxPro example code creates an array and initializes it to type Character. MYFUNC( ) passes this array by reference.

Visual FoxPro Code

SET LIBRARY TO STRCPY  
? STRCPY("Hello", " world")   && returns "Hello world"

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
#define p0 (parm->p[0].val)
#define p1 (parm->p[1].val)

   if (!_SetHandSize(p0.ev_handle, p0.ev_length + p1.ev_length))
      _Error(182); // "Insufficient memory"
   _HLock(p0.ev_handle);
   _HLock(p1.ev_handle);
   ((char FAR *) _HandToPtr(p1.ev_handle))[p1.ev_length] = '\0';

   _StrCpy((char FAR *) _HandToPtr(p0.ev_handle) + p0.ev_length,
      _HandToPtr(p1.ev_handle));

   _RetChar(_HandToPtr(p0.ev_handle));
   _HUnLock(p0.ev_handle);
   _HUnLock(p1.ev_handle);
}
FoxInfo myFoxInfo[] = {
   {"STRCPY", (FPFI) Example, 2, "C,C"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};