home *** CD-ROM | disk | FTP | other *** search
-
- #define NOCOMM
- #include <windows.h>
-
- #include "hugearr.h"
-
- /* Load a huge array that was previously saved in an operating system file. */
- /* VBM: Declare Function VBHugeLoad& Lib "hugearr.dll" Alias "VBHugeLoad" (ByVal hArray%, ByVal RecLen%, ByVal Fn$) */
- long FAR PASCAL
- VBHugeLoad(int hArray, int InLen, LPSTR FileSpec)
- {
- int BytesRead; /* number of bytes read from the file */
- int hLoadFile; /* handle to the save file */
- HPBYTE ToBegin; /* pointer for first element */
- HPBYTE ToElem; /* pointer to array element */
- long element; /* element in the huge array */
- PHUGEDESC pArray; /* pointer to array descriptor */
-
- DecCheckHandle(hArray);
-
- pArray = (PHUGEDESC) LocalLock(hLocalMem) + hArray;
-
- CheckNotAllocYet(pArray);
-
- /* Open the file */
- if((hLoadFile = _lopen(FileSpec, OF_READ)) < 0)
- {
- LocalUnlock(hLocalMem);
- return HA_FILEOPENERROR;
- }
-
- ToBegin = (HPBYTE) GlobalLock(pArray -> handle);
-
- for(element = 0L; element <= pArray -> ubound ; element++)
- {
- /* calculate pointer to element */
- ToElem = ToBegin + HugeElementOffset(element, pArray->perseg, pArray->recsize);
-
- /* Read the record */
- BytesRead = _lread(hLoadFile, ToElem, InLen);
-
- if (BytesRead < 0)
- element = HA_FILEREADERROR;
- if (BytesRead <= 0)
- break;
- }
-
- /* Wrap up and return */
- GlobalUnlock(pArray -> handle);
- LocalUnlock(hLocalMem);
- _lclose(hLoadFile);
- return element;
- }
-