|
All of the changes discussed so far have been exclusive to the DDFs or the ActiveX memory image of the DDFs. Changing the DDFs, however, does not alter the length or structure of the actual records in the data file. To do this, you need to make use of the functions that directly affect the data file.
Changing the length of a data file is not a one-operation issue. Essentially, the data file must be destroyed and rebuilt with the new length. If this is done to an existing file, the records should be copied using two VAccess controls and a temporary file. For example:
To add a field to a table and a data file:
totalRecords = VAccess1.TotalRecords currRec = 0 While currRec < totalRecords VAccess2.Buffer(0) = VAccess1.Buffer(0) VAccess2.Insert 'add error handling here VAccess1.GetNext currRec = currRec + 1 Wend VAccess1.Close VAccess2.Close 'Now we have two data files - one with the old data & one 'with the new. Use language API to delete the old data 'file and rename the new data file to the old name RenameTempDataFile 'Reset the location to the correct location - don't change 'DDF, as it should be fine already VAccess2.DdfModifyLocation VAccess1.Location
There are other modifications that can be performed directly to the index structure of the data file. These operations can be found in ActiveX Method Reference and include DdfAddIndex, DdfDropIndex, and DdfDropIndexMaintain.
|
Chapter contents
Prev topic: Creating a Dictionary
|