2.2 Btrieve Object

The only object of the Btrieve UCX component. Provides access to Btrieve C commands.

2.2.1 DataBuffer property

Contains the output of the previous Btrieve operation. If the last operation was a record read, this property will contain the last read record from the Btrieve database.

Syntax

 object.DataBuffer
 

Type

String.

Attributes

Read-only.

Example

This DataBuffer example contains the output of the last Btrieve operation.

      ’Helper Functions 
      Function LowHigh(param1) 
      ’Change the integer byte order and return result as a binary string. 
           m = CInt(param1 Mod 256)  
           n = Int(param1/256) 
           LO = Chr(m) 
           HI = Chr(n) 
           LowHigh = (LO+HI) 
      End Function 
      ’Make index 
      Function BTXIndexMake(param1, param2, param3) 
           KeyPos = LowHigh(param1) 
           KeyLen = LowHigh(param2) 
           KeyFlags = LowHigh(param3) 
           xyz = LowHigh(0) + LowHigh(0) 
           XkeyType = Chr(0) 
           Reserved3 = chr(0) + chr(0) + chr(0) 
           Mkey = Chr(0) 
           ACS = Chr(0) 
           KeySpec = KeyPos + KeyLen + KeyFlags + xyz + XKeyType 
           KeySpec = KeySpec + Reserved3 + MKey + ACS 
           BTXIndexMake = KeySpec 
      End Function 
     ’Make the record by filling required fields 
      Function BTXRecordMake(param1 , param2 , param3 ) 
           RecLen = LowHigh(param1) 
           PageSize = LowHigh(param2) 
           Indexes = LowHigh(param3) 
           ’4 Bytes 
           Reserved4 = Chr(0) + Chr(0) + Chr(0) + Chr(0) 
           ’2 Bytes 
           FileFlags = LowHigh(0)  
           ’2 Bytes (dup pointers and reserved) 
           Reserved2 = Chr(0) + Chr(0) 
           ’2 Bytes 
           PreAlloc = LowHigh(0) 
           FileSpec = RecLen + PageSize + Indexes + Reserved4 + FileFlags 
           FileSpec = FileSpec + Reserved2 + PreAlloc 
           BTXRecordMake = FileSpec 
      End Function 
      ’End helper functions 
   sub main 
      ’Open a btrieve database file 
      ’Read a record from the btrieve database 
      set btxobj = createobject ("UCX:Btrieve.Database") 
      ’Make a filespec buffer with record length, page size, index 
      FileSpec = BTXRecordMake(30,1024,2 ) 
      ’Make index 
      FileSpec = FileSpec + BTXIndexMake(1,10,BTX_DUP) 
      FileSpec = FileSpec + BTXIndexMake(11,10,BTX_DUP) 
      keylen=0 
      RetVal = btxobj.Call ( BTX_OPEN, FileSpec, 
      en(FileSpec),"Sys:\BTRV.BTV",keylen) 
      keylen = 0 
      KeyBuf = Space(15) 
      RetVal = btxobj.Call ( BTX_GET_FIRST, FileSpec, Len(FileSpec), Keybuf, 
      keylen) 
      print (btxobj.DataBuffer 
 end sub
 

2.2.2 KeyBuffer property

Contains the key information of the last read record. The content depends on the task and command initiated.

Syntax

 object.KeyBuffer
 

Type

String.

Attributes

Read-only.

Example

This KeyBuffer example contains the key information from the last read record.

      ’ Helper Functions 
      Function LowHigh(param1) 
      ’Change the integer byte order and return result as a binary string. 
           m = CInt(param1 Mod 256)  
           n = Int(param1 / 256) 
           LO = Chr(m) 
           HI = Chr(n) 
           LowHigh = (LO+HI) 
      End Function 
      ’ Make index 
      Function BTXIndexMake(param1, param2, param3) 
           KeyPos = LowHigh(param1) 
           KeyLen = LowHigh(param2) 
           KeyFlags = LowHigh(param3) 
           xyz = LowHigh(0) + LowHigh(0) 
           XkeyType = Chr(0) 
           Reserved3 = chr(0) + chr(0) + chr(0) 
           Mkey = Chr(0) 
           ACS = Chr(0) 
           KeySpec = KeyPos + KeyLen + KeyFlags + xyz + XKeyType 
           KeySpec = KeySpec + Reserved3 + MKey + ACS 
           BTXIndexMake = KeySpec 
      End Function 
      ’Make the record by filling required fields 
      Function BTXRecordMake(param1 , param2 , param3 ) 
           RecLen = LowHigh(param1) 
           PageSize = LowHigh(param2) 
           Indexes = LowHigh(param3) 
           ’4 Bytes 
           Reserved4 = Chr(0) + Chr(0) + Chr(0) + Chr(0) 
           ’2 Bytes 
           FileFlags = LowHigh(0)  
           ’2 Bytes (dup pointers and reserved) 
           Reserved2 = Chr(0) + Chr(0) 
           ’2 Bytes 
           PreAlloc = LowHigh(0) 
           FileSpec = RecLen + PageSize + Indexes + Reserved4 + FileFlags 
           FileSpec = FileSpec + Reserved2 + PreAlloc 
           BTXRecordMake = FileSpec 
      End Function 
      ’End helper functions 
 sub main   
      ’Read the last record from the btrieve database 
      set btxobj = createobject ("UCX:Btrieve.Database") 
      ’Make a filespec buffer with record length, page size, index 
      FileSpec = BTXRecordMake(30,1024,2 ) 
      ’Make index 
      FileSpec = FileSpec + BTXIndexMake(1,10,BTX_DUP) 
      FileSpec = FileSpec + BTXIndexMake(11,10,BTX_DUP) 
      keylen=0 
      RetVal = btxobj.Call( BTX_OPEN, FileSpec, Len(FileSpec),"Sys:\btrv.BTV",keylen) 
      keylen = 0 
      KeyBuf = Space(15) 
      RetVal = btxobj.Call ( BTX_GET_LAST, FileSpec, Len(FileSpec), Keybuf, 
      keylen) 
      print (btxobj.KeyBuffer) 
 end sub
 

2.2.3 Call method

Performs various operations on the Btrieve database.

Syntax

 object.Call(
    Action As Integer, 
    DataBuffer As String, 
    BufferLength As Integer, 
    KeyBuffer As String, 
    NumberOfKeys As Integer)
 

Parameters

Action
Btrieve operation to be performed. Some common values for Action are
  • BTX_CREATE
  • BTX_OPEN
  • BTX_CLOSE
  • BTX_GET_FIRST
  • BTX_GET_LAST
  • BTX_INSERT
  • BTX_DELETE

For a complete list, see Btrieve Constants.

DataBuffer
An I/O buffer for the Btrieve operations.
BufferLength
The length of the DataBuffer in number of bytes.
KeyBuffer
An I/O buffer for the Btrieve operations.
NumberOfKeys
The access paths to be followed for a particular operation. This parameter can have any value between 0 and 118.

Return Values

Integer. 0 if successful; otherwise, an error code. For a list of error codes and their descriptions, see "Appendix B" of the NetWare Btrieve Programmer's manual (available in hard copy only).

Remarks

This method is used to used to perform various operations on the Btrieve database, such as creating a file, opening a file, closing a file, reading records, and deleting records. The DataBuffer and KeyBuffer parameters are used as I/O buffers for the database operations.

Example

This Call example performs several functions, including opening the Btrieve database (BTX_OPEN) and getting the first record (BTX_GET_FIRST) in the database.

      ’ Helper Functions 
      Function LowHigh(param1) 
      ’ Change the integer byte order and return result as a binary string. 
           m = CInt(param1 Mod 256)  
           n = Int(param1 / 256) 
           LO = Chr(m) 
           HI = Chr(n) 
           LowHigh = (LO+HI) 
      End Function 
      ’Make index 
      Function BTXIndexMake(param1, param2, param3) 
           KeyPos = LowHigh(param1) 
           KeyLen = LowHigh(param2) 
           KeyFlags = LowHigh(param3) 
           xyz = LowHigh(0) + LowHigh(0) 
  
           XkeyType = Chr(0) 
           Reserved3 = chr(0) + chr(0) + chr(0) 
           Mkey = Chr(0) 
           ACS = Chr(0) 
           KeySpec = KeyPos + KeyLen + KeyFlags + xyz + XKeyType 
           KeySpec = KeySpec + Reserved3 + MKey + ACS 
           BTXIndexMake = KeySpec 
      End Function 
      ’Make the record by filling required fields 
      Function BTXRecordMake(param1 , param2 , param3 ) 
           RecLen = LowHigh(param1) 
           PageSize = LowHigh(param2) 
           Indexes = LowHigh(param3) 
           ’4 Bytes 
           Reserved4 = Chr(0) + Chr(0) + Chr(0) + Chr(0) 
           ’2 Bytes 
           FileFlags = LowHigh(0)  
           ’2 Bytes (dup pointers and reserved) 
           Reserved2 = Chr(0) + Chr(0) 
           ’2 Bytes 
           PreAlloc = LowHigh(0) 
           FileSpec = RecLen + PageSize + Indexes + Reserved4 + FileFlags 
           FileSpec = FileSpec + Reserved2 + PreAlloc 
           BTXRecordMake = FileSpec 
      End Function 
      ’End helper functions 
 sub main   
      ’Open a btrieve database file 
      ’Read a record from the btrieve database 
      set btxobj = createobject ("UCX:Btrieve.Database") 
      ’Make a filespec buffer with record length, page size, index 
      FileSpec = BTXRecordMake(30,1024,2 ) 
      ’Make index 
      FileSpec = FileSpec + BTXIndexMake(1,10,BTX_DUP) 
      FileSpec = FileSpec + BTXIndexMake(11,10,BTX_DUP) 
      keylen=0 
      RetVal = btxobj.Call( BTX_OPEN, FileSpec, Len(FileSpec),"Sys:\btrv.BTV",keylen) 
      KeyBuf = Space(15) 
      RetVal = btxobj.Call ( BTX_GET_LAST, FileSpec, Len(FileSpec), Keybuf, 0) 
      print (btxobj.DataBuffer) 
      ’Close the file 
      RetVal = btxobj.Call( BTX_CLOSE, FileSpec,Len(FileSpec),"Sys:\btrv.BTV",0) 
 end sub