Category : BASIC Source Code
Archive   : HUGARY.ZIP
Filename : HUGESET.C

 
Output of file : HUGESET.C contained in archive : HUGARY.ZIP


#define NOCOMM
#include
#include

#include "hugearr.h"

/* Set a huge array element. */
/* VBM: Declare Function VBHugeSet% Lib "hugearr.dll" Alias "VBHugeSet" (ByVal Index%, ByVal el&, buffer As Any) */
int FAR PASCAL
VBHugeSet(int hArray, long element, LPBYTE buffer)
{
HPBYTE ptr; /* pointer to array element */
PHUGEDESC pArray; /* pointer to array descriptor */

DecCheckHandle(hArray);

/* point to proper descriptor */
pArray = (PHUGEDESC) LocalLock(hLocalMem) + hArray;

CheckNotAllocYet(pArray);
CheckSubscript(pArray, element, element);

/* calculate pointer to element */
ptr = (HPBYTE) GlobalLock(pArray -> handle);

/* add offset of element */
ptr += HugeElementOffset(element, pArray->perseg, pArray->recsize);

/* copy data */
_fmemcpy(ptr, buffer, pArray -> recsize);

GlobalUnlock(pArray -> handle);
LocalUnlock(hLocalMem);
return HA_OK;
}