JavaScript Editor js editor     Web development 

Main Page

Copies length bytes starting from src to dest.

void _MemMove(void FAR *dest, void FAR *src, unsigned int length)
void FAR *dest;            /* Destination. */
void FAR *src;               /* Starting position. */
unsigned int length;         /* How many bytes to move. */


Overlapping moves are performed in the appropriate direction to prevent data corruption.

For more information on how to create an API library and integrate it with Visual FoxPro, see see Accessing the Visual FoxPro API.


The following example uses _MemMove(В ) to implement a substring function. From Visual FoxPro, MEMMOVE(s, n1, n2) returns the substring of s starting from position n1 and through position n2.

Visual FoxPro Code

В Copy Code
? MEMMOVE("Hello, world.", 8, 10)  && returns "wor"

C Code

В Copy Code
#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
   int SubstrLen;
   MHANDLE bufferHandle;
   char FAR *FirstDest;

   SubstrLen = parm->p[2].val.ev_long - parm->p[1].val.ev_long + 1;
   if ((bufferHandle = _AllocHand(SubstrLen + 1)) == 0)
      _Error(182); // "Insufficient memory"
   FirstDest = (char FAR *) _HandToPtr(parm->p[0].val.ev_handle) +
      parm->p[1].val.ev_long - 1;

   _MemMove(_HandToPtr(bufferHandle), FirstDest, SubstrLen);

   ((char FAR *) _HandToPtr(bufferHandle))[SubstrLen] = '\0';
FoxInfo myFoxInfo[] = {
   {"MEMMOVE", (FPFI) Example, 3, "C,I,I"},
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo

See Also

JavaScript Editor js editor     Web development