>with This > do case > case type('.DataEnvironment') <> 'O' or ; > .DataEnvironment.AutoOpenTables > case type('oApp.Name') = 'C' and ; > pemstatus(oApp, 'SetDataDirectory', 5) > oApp.SetDataDirectory(.DataEnvironment) > .DataEnvironment.OpenTables() > otherwise > .DataEnvironment.OpenTables() > endcase >endwith>- My application object (instantiated into oApp) has the following code in its SetDataDirectory method:
lparameters toDE >local laObjects[1], ; > lnObjects, ; > lcDirectory, ; > lcCommon, ; > lnI, ; > loObject, ; > lcDatabase, ; > lcTable > >* Get a list of the members of the DataEnvironment, and get >* the data directory from the cDataDir property. > >lnObjects = amembers(laObjects, toDE, 2) >lcDirectory = This.cDataDir > >* Look at each member object, but only process cursors. > >for lnI = 1 to lnObjects > loObject = evaluate('toDE.' + laObjects[lnI]) > if upper(loObject.BaseClass) = 'CURSOR' > lcDatabase = loObject.Database > >* If this is a free table, adjust the CursorSource property. > > if empty(lcDatabase) > lcTable = loObject.CursorSource > loObject.CursorSource = lcDirectory + ; > substr(lcTable, rat('\', lcTable) + 1) > >* This cursor is part of a database, so change the database property. > > else > loObject.Database = lcDirectory + ; > substr(lcDatabase, rat('\', lcDatabase) + 1) > endif empty(lcDatabase) > endif upper(loObject.BaseClass) = 'CURSOR' >next lnI>