brCreateFile method

Creates a new instance of the clsD3File class and opens the specified D3 file in the current account.

Syntax

Set oFile = object.brCreateFile(sDictFlag, sFileName, vModulo1, [vnModulo2], [vnFrameSize])

Parameters

Parameter Description
oFile An object variable that represents a clsD3File object to be created.
object An object variable that represents a clsD3Connection object.
sDictFlag A String. Use "dict" to create a dictionary-only. Use "" (an empty string) to create a data level or both a dictionary and data level.
sFileName A String specifying the name of the file to be created. Path names to other accounts may not be used.
nModulo1 A Long specifying the modulo number of the dictionary.
vnModulo2 Optional. A Variant (Long subtype) specifying the modulo number for the data level. If omitted, then the modulo of the data level is the same as the dictionary, specified by nModulo1.
VnFrameSize Optional. Not implemented.

Remarks

The following creates in the current account a dictionary-only file called products:

Set oFile1 = oConn. brCreateFile("dict", "products", 1)

The following creates a dictionary and data file called products, unless the dictionary already exists. If the dictionary already exists, then just a data level, called products, is created:

Set oFile2 = oConn. brCreateFile("", "products", 1, 3)

The following creates an additional data level on the products file called new.prod:

Set oFile3 = oConn.brCreateFile("", "products,new.prod", 1, 3)

Example

Private Sub UpdateLog(oConn As clsD3Connection, aTask As clsD3DynamicArray)
   Dim oFile As clsD3File
   Dim sLogName As String
   Dim aItem As New clsD3DynamicArray
   Dim sItemName As String
 
   On Error GoTo D3ErrorHandler
 
   sLogName = "daily" & oConn.brDate & ".log"
   Set oFile = oConn.brOpenFile(sLogName)
 
   oFile.brFileLock
 
   ' Item-id will be the time.
   sItemName = oConn.brTime
   oFile.brWrite aTask, sItemName
 
   oFile.brFileUnlock
 
   oConn.brCloseFile oFile
   Set aItem = Nothing
Exit Sub
 
D3ErrorHandler:
   Select Case Err.Number
      Case d3SrvErr_Missing
         oConn.brCreateFile"", sLogName, 3, 31
      Case Else
         End
      End Select
      Resume
End Sub

TCL reference

create-file