home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / wbtrv.zip / BTRVRECO.CLS < prev    next >
Text File  |  1990-11-02  |  3KB  |  132 lines

  1. /* Copyright (c) 1990, Silverwood Software
  2.  * Placed in the public domain, 11/01/90
  3.  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4.  * Methods and variables used to send and receive data to and from
  5.  * Btrieve structured databases */!!
  6.  
  7. inherit(Record, #BtrvReco, #(posBlk  /* 128 byte Struct */
  8. datBuf  /*  initialized as a String */
  9. datLen  /* 2 byte Struct */
  10. keyBuf  /* 255 byte Struct */
  11. keyLen  /* always equal to 255 */
  12. ndx  /* current index path number */
  13. ), 2, nil)!!
  14.  
  15. now(class(BtrvReco))!!
  16.  
  17. now(BtrvReco)!!
  18.  
  19. /* Get data buffer length - word:
  20.  * Return the current data buffer length as a word */
  21. Def getDLen(self)
  22. { ^wordAt(datLen,0)}
  23. !!
  24.  
  25. /* Load fields from "datBuf" into the "flds" array.  "flds" is inherited
  26.  * from the Record class.  posArray is an array of field position numbers
  27.  * for fixed fields in the Btrieve database and sizeArray is a coresponding
  28.  * array of field size values. */
  29. Def loadFldsArray(self,posArray,sizeArray | ct)
  30. { ct:=0;
  31.   do(posArray,
  32.     { using(e)
  33.       flds[ct]:=subString(datBuf,e,e+sizeArray[ct]);
  34.       ct:=inc(ct);
  35.     });  
  36. }
  37. !!
  38.  
  39. /* Initialize instance variables used with the Actor 
  40.  * pcall statement */
  41. Def initReco(self,datBufLen,nbOfFlds)
  42. { posBlk:=new(Struct,128);
  43.   datBuf:=new(String,datBufLen);
  44.   datLen:=new(Struct,2);
  45.   putWord(datLen,datBufLen,0);
  46.   keyLen:=255;
  47.   keyBuf:=new(Struct,keyLen);
  48.   setNdx(self,0);
  49.   initFlds(self,nbOfFlds);
  50. }
  51. !!
  52.  
  53. /* Set the Btrieve index path number */
  54. Def setNdx(self,keyVal)
  55. { ndx:=keyVal;
  56. }
  57. !!
  58.  
  59. /* Put a string value into the current key buffer */
  60. Def setKeyBuf(self,strg)
  61. { fill(keyBuf,0);
  62.   if strg<>nil then
  63.     memcpy(keyBuf,strg,size(strg));
  64.   endif;  
  65. }
  66. !!
  67.  
  68. /* Set data buffer length */
  69. Def setDatLen(self,length)
  70. { if length=nil then
  71.     length=0;
  72.   endif;  
  73.   putWord(datLen,length,0);
  74. }
  75. !!
  76.  
  77. /* Create new data buffer */
  78. Def setDatBuf(self,length)
  79. { if length<>nil cand length<>0 then
  80.     datBuf:=new(String,length);
  81.   endif;  
  82. }
  83. !!
  84.  
  85. /* load record into datBuf for Btrv Insert or Update. */
  86. Def loadDatBuf(self,strg)
  87. { if strg<>nil then
  88.     memcpy(datBuf,strg,size(strg));
  89.   endif;  
  90. }
  91. !!
  92.  
  93. /* Get position block:
  94.  * Return the current position block */
  95. Def gPBlk(self)
  96. { ^posBlk}
  97. !!
  98.  
  99. /* Get key index number:
  100.  * Return the current index path */
  101. Def gKNdx(self)
  102. { ^ndx}
  103. !!
  104.  
  105. /* Get data buffer length - Struct:
  106.  * Return the current data buffer length as a Struct */
  107. Def gDLen(self)
  108. { ^datLen}
  109. !!
  110.  
  111. /* Get key buffer:
  112.  * Return the current key buffer */
  113. Def gKBuf(self)
  114. { ^keyBuf}
  115. !!
  116.  
  117. /* Get data buffer: 
  118.  * Return the current data buffer */
  119. Def gDBuf(self)
  120. { ^datBuf}
  121. !!
  122.  
  123. /* load direct address into datBuf for Btrv GetDirect call. */
  124. Def dirAddrToDatBuf(self,dirAddr)
  125. { if dirAddr=nil then
  126.     ^0;
  127.   endif;  
  128.   memcpy(datBuf,dirAddr,4);
  129.   ^1;
  130. }
  131. !!
  132.