This weekend, I have changed an app that is currently in use by about 200 people at work. The change is great, but it requires that various databases (about 100 discrete Dbase tables) need to have a new field.
Therefore, I want to check each database as they are opened and see if the new field exists. If the field does not exist, I want to add it. The code shown below doesn't bomb out, but the field isn't added either!
If you see the problem, please let me know.
var TableTemp : TTable;
bFlag : Boolean;
iCounter : Integer;
// Create and open existing table
TableTemp := TTable.Create(Self);
TableTemp.DatabaseName := '<< PATH >>';
TableTemp.TableName := 'INDEX.DBF';
// Check fields for one called 'REF'
For iCounter := 0 to TableTemp.FieldCount-1 do
If UpperCase(TableTemp.Fields[iCounter].Fieldname = 'REF' then
bFlag := True;
// Flag not set = Field not found
If bFlag = False then
// All done - tidy up.