brRoot method

Creates a new instance of the clsD3Index class and opens the index with the specified a-correlative on the D3 file.

Syntax

Set oIndex = object.brRoot( sCorrelative)

Parameters

Parameter Description
oIndex An object variable that represents a clsD3Index object to be created.
object An object variable that represents a clsD3File object.
sCorrelative A String containing an a-correlative.

Example

Sub Main()
   Dim oEnv As New clsD3Environment
   Dim oConn As clsD3Connection
   Dim oFile As clsD3File
   Dim oIndex As clsD3Index
 
   Set oConn = oEnv.brOpenConnection("ODBC", "Production") 
   Set oFile = oConn.brOpenFile("customers")
 
   On Error GoTo D3ErrorHandler
 
   ' If there is not an existing index on attribute 1,
   ' then the D3ErrorHandler will create an index.
   Set oIndex = oFile.brRoot("a1")
 
   ' brMoveNext is the first index function to
   ' be performed so the index will be traversed
   ' from the beginning.
   Do While oIndex.brMoveNext
      ' brIndexId returns the item-ids from the
      ' customers file that is the customerid.
      ' brIndexKey returns the customer's name (attribute1).
      Debug.Print oIndex.brIndexId, oIndex.brIndexKey
   Loop
 
   oConn.brCloseFile oFile
   oEnv.brCloseConnection oConn
   Set oEnv = Nothing
Exit Sub
 
D3ErrorHandler:
   Select Case Err.Number
      Case d3SrvErr_NotRoot
         oFile.brCreateIndex "a1", True
      Case Else
      End
 
   End Select
   Resume
End Sub

FlashBASIC reference

root

Applies to

clsD3File class