Here's the code I use to handle the situation where a user installs to a different directory than the one on which I created the app. It's a .prg to which you pass a dataenvironment. It sets the Database property of all cursors in the DE to the current directory plus \Data, and opens that database. It should be modifiable for your needs.
* changes cursors' Database property to current directory + \Data
* opens the database
lparameters toDE
Assert Type("toDE.Name") == 'C'
if !(Type("toDE.Name") == 'C')
return
endif
Assert Upper(toDE.Class) == Upper("DataEnvironment")
if !(Upper(toDE.Class) == Upper("DataEnvironment"))
return
endif
* get all the cursors in the Data Environment
local laCursors[1]
AMembers(m.laCursors, toDE, 1)
* iterate through each cursor
local llFirst
llFirst = .T.
local ln
for ln = 1 to ALen(laCursors, 1)
* skip non-objects
if !laCursors[ln, 2] == "Object"
loop
endif
* get the object name
local lcObject
lcObject = "toDE." + laCursors[ln, 1]
* change the path to the database to the current folder + \Data
if Eval(m.lcObject + ".Class") == "Cursor"
Local loCursor
loCursor = Eval(m.lcObject)
loCursor.Database = Sys(5) + Sys(2003) + "\Data\" +;
JustFName(loCursor.Database)
if llFirst
open database (loCursor.Database)
llFirst = .F.
endif
endif
endfor
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only