|
Previous versions of the ActiveX interface 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 interface, 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 interface 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 interface 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:
To fill a list box with the table names in the current dictionary:
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.
|
Chapter contents
Prev topic: File Contents vs. Memory Image
|