PreviousActiveX Controls Guide (9.1 revision 1) Next

Creating a Table Definition

Show this topic in Library frames

Creating a table in the ActiveX interface memory image (and in the DDFs) can be useful when a data file has no DDF entry associated with it or when creating a new table. The process includes three basic steps:

  1. Create an empty table in the ActiveX interface memory image.
  2. Populate the ActiveX interface memory image with the appropriate table, field, and index information.
  3. Save the new table to the DDFs.

If you are creating a new table, this would be followed by a fourth step, creating the data file.

When creating an empty table, the ActiveX interface must know that the working table should not exist in the current memory image and that all the field and index information should be cleared out. DdfAddTableName serves this function. Unlike DdfAddTable (which adds the current table memory image to the DDF) or DdfModifyTableName (which changes the current table name but maintains all other information), DdfAddTableName creates an extra slot in the current table list and clears out all of the field and index information associated with the blank table. It is recommended that RefreshLocations be set to False when this is done, so as not to create an empty table in the DDFs.

The new, empty memory image can be populated with the DdfModifyLocation, FieldList, and IndexList operations. It can then be written out to the DDFs with DdfAddTable.

To add a new table to a dictionary:

Option Base 0 
'Get the current information directly from the DDF
VAccess1.RefreshLocations = True 
'Set the VAccess to the correct DDF
VAccess1.DdfPath = "c:\myData" 
'We now want to work only with the memory image while we 'set up the table
VAccess1.RefreshLocations = False 
'Create the new table slot in the current memory image
VAccess1.DdfAddTableName "NewTable" 
'Set the Location
VAccess1.DdfModifyLocation "newTable.mkd" 
.... 
<set the field and index information> 
.... 
'Save the table to the file - do not overwrite the existing 'definition
'because there should be no existing definition
DdfAddTable False 
 

Note
An entire table definition can be dropped with one call to DdfDropTable. As might be expected, this operation suggests a high degree of finality and should be used with caution.

Chapter contents
Publication contents

Prev topic: Modifying the DDF
Next topic: Creating a Dictionary