Reading a Dictionary File
Previous versions of the ActiveX access method exposed much of the information contained in the DDFs, but made it very difficult (and sometimes impossible) to retrieve certain information. In addition, retrieving more than one item of information was tedious because multiple property settings were required for each item. In this version of the ActiveX access method, variant arrays have been used to solve these problems. A variant is a type of variable that can represent multiple data types and that knows which data type it currently represents. The ActiveX access method containers support variants.
A variant array is a type of variant that is actually a reference to a list of variants, each of which may hold a different type of information. This array may be represented in different forms, depending on the coding environment. In Visual Basic, a variant array will appear as just a normal array, e.g., myArray(1, 1). In Visual C++, however, a variant array will simply be a variant of type VT_ARRAY|VT_VARIANT, and the “SafeArray” system APIs must be used to manipulate the array contents.
As mentioned previously, the ActiveX access method uses variant arrays to expose core DDF information. The arrays that it uses are two-dimensional arrays that have the column as the first dimension and the row as the second dimension (this ordering allows Visual Basic users to use the ReDim Preserve function to change the number of rows). The columns represent various facets of the requested information while the rows represent the collection of items. For instance, GetTableList returns a two-dimensional array. The first dimension consists of three pieces of information—TableID, TableName, and TableLocation—while the second dimension contains one row for each table in the dictionary. Getting a list of table names in Visual Basic, therefore, would be done as follows:
Dim tableList as Variant
Dim tableCount as integer
 
'Make sure we’re reading everything from the file itself
VAccess1.RefreshLocations = True
 
'Set the DdfPath – this will open the dictionary
VAccess1.DdfPath = “c:\mydata”
 
'get the variant array
tableList = VAccess1.GetTableList
'fill a listbox with the names – loop until we reach the 'upper bound of the array
For tableCount = 0 to UBound(tableList, 2)
'Add the correct member of the array to the listbox
List1.AddItem tableList(1, tableCount)
Next tableCount
FieldList and IndexList work much the same way. But because they are properties, they allow you to modify or add entries to the array. See FieldList and IndexList for information on the structure of the first dimension of each array. The second dimension of each array would of course represent the number of fields or indexes.