home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
windows
/
wbtrv.zip
/
BTRVRECO.CLS
< prev
next >
Wrap
Text File
|
1990-11-02
|
3KB
|
132 lines
/* Copyright (c) 1990, Silverwood Software
* Placed in the public domain, 11/01/90
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Methods and variables used to send and receive data to and from
* Btrieve structured databases */!!
inherit(Record, #BtrvReco, #(posBlk /* 128 byte Struct */
datBuf /* initialized as a String */
datLen /* 2 byte Struct */
keyBuf /* 255 byte Struct */
keyLen /* always equal to 255 */
ndx /* current index path number */
), 2, nil)!!
now(class(BtrvReco))!!
now(BtrvReco)!!
/* Get data buffer length - word:
* Return the current data buffer length as a word */
Def getDLen(self)
{ ^wordAt(datLen,0)}
!!
/* Load fields from "datBuf" into the "flds" array. "flds" is inherited
* from the Record class. posArray is an array of field position numbers
* for fixed fields in the Btrieve database and sizeArray is a coresponding
* array of field size values. */
Def loadFldsArray(self,posArray,sizeArray | ct)
{ ct:=0;
do(posArray,
{ using(e)
flds[ct]:=subString(datBuf,e,e+sizeArray[ct]);
ct:=inc(ct);
});
}
!!
/* Initialize instance variables used with the Actor
* pcall statement */
Def initReco(self,datBufLen,nbOfFlds)
{ posBlk:=new(Struct,128);
datBuf:=new(String,datBufLen);
datLen:=new(Struct,2);
putWord(datLen,datBufLen,0);
keyLen:=255;
keyBuf:=new(Struct,keyLen);
setNdx(self,0);
initFlds(self,nbOfFlds);
}
!!
/* Set the Btrieve index path number */
Def setNdx(self,keyVal)
{ ndx:=keyVal;
}
!!
/* Put a string value into the current key buffer */
Def setKeyBuf(self,strg)
{ fill(keyBuf,0);
if strg<>nil then
memcpy(keyBuf,strg,size(strg));
endif;
}
!!
/* Set data buffer length */
Def setDatLen(self,length)
{ if length=nil then
length=0;
endif;
putWord(datLen,length,0);
}
!!
/* Create new data buffer */
Def setDatBuf(self,length)
{ if length<>nil cand length<>0 then
datBuf:=new(String,length);
endif;
}
!!
/* load record into datBuf for Btrv Insert or Update. */
Def loadDatBuf(self,strg)
{ if strg<>nil then
memcpy(datBuf,strg,size(strg));
endif;
}
!!
/* Get position block:
* Return the current position block */
Def gPBlk(self)
{ ^posBlk}
!!
/* Get key index number:
* Return the current index path */
Def gKNdx(self)
{ ^ndx}
!!
/* Get data buffer length - Struct:
* Return the current data buffer length as a Struct */
Def gDLen(self)
{ ^datLen}
!!
/* Get key buffer:
* Return the current key buffer */
Def gKBuf(self)
{ ^keyBuf}
!!
/* Get data buffer:
* Return the current data buffer */
Def gDBuf(self)
{ ^datBuf}
!!
/* load direct address into datBuf for Btrv GetDirect call. */
Def dirAddrToDatBuf(self,dirAddr)
{ if dirAddr=nil then
^0;
endif;
memcpy(datBuf,dirAddr,4);
^1;
}
!!