Modifying a Dictionary File
Modifying a file in the ActiveX memory image is useful as the first stage of a DDF new definition add or change and commit process, or in correcting information in an incorrect DDF. Most of the changes that need to be made can be done by using the FieldList and IndexList properties.
When changing the DDFs, it is usually more efficient to store the changes in the ActiveX memory image until all changes are ready, and then commit them to the file using DdfAddTable. Thus, it is better to set RefreshLocations to False when setting FieldList or IndexList. You can add a field to an existing definition in Visual Basic by using the ReDim function with the Preserve option. And you can use DdfModifyTableName and DdfModifyLocation to alter the table either in the current memory image or in the DDF file itself. For example:
Option Base 0
Dim fields as Variant
 
'Get the current information directly from the DDF
VAccess1.RefreshLocations = True
 
'Set the VAccess to the correct DDF & the correct table
VAccess1.DdfPath = “c:\myData”
VAccess1.TableName = “TableShortAField”
 
'Get the fieldList
fields = VAccess1.FieldList
 
'Redimension it & add a field
ReDim Preserve fields(7, UBound(fields, 2) + 1)
 
'now we have the same array as before, but with an extra, 'empty field at the end
'define the empty field
fields(1, UBound(fields, 2)) = “NewComment”
fields(2, UBound(fields, 2)) = 0 'String
fields(3, UBound(fields, 2)) = VAccess1.DataLength
fields(4, UBound(fields, 2)) = 20 ’20 byte string
fields(7, UBound(fields, 2)) = “This is a new comment”
 
'We don’t want to write this change to the file just yet
VAccess1.RefreshLocations = False
'Save the empty field to the ActiveX memory image
VAccess1.FieldList = fields
 
....
<Do more DDF processing>
....
'Ok, our table is set up like we want it. Let’s change the 'name of the table
DdfModifyTableName “TableWithAllFields”
 
'We want the next operation to affect the DDFs directly, 'so we could set RefreshLocations.
'However, DdfAddTable only affects the DDFs (and not 'the memory image), so it
'ignores RefreshLocations (see DdfAddTable in the 'Reference section).
 
'Save the table to the file – overwrite the existing 'definition
DdfAddTable True
*Note: The changes demonstrated in the previous example affect the DDF only. If the table itself does not have room for this extra field, the field will not exist in the file itself. See the following section for information on altering the data file’s structure.