General information
Category:
Forms & Form designer
>>Yes, but once you have your desired path, from the .ini or CURDIR() or wherever, what command is it that sets a path that OpenTables() will use when it looks for the table? Or are you editing the .scx directly?
>
>Each cursor in the DE has a Database and CursorSource properties which may need to be adjusted.
I just thought I'd show you what I made, so you can spot potential problems. It seems to work perfectly, but it hasn't been bashed around a lot yet. For the benefit of readers who didn't see the cut-off part of this thread, my question was: how do I make data environments ignore their hard-coded .database field, and look in the current directory instead? I think this is right:
In the Form or Formset.load
oChangeDataPath = CREATEOBJECT('datafolder')
oForm = THISFORM (or THISFORMSET)
oChangeDataPath.curfolder(oForm)
RELEASE oChangeDataPath
RELEASE oForm
and I have a custom class called datafolder with a curfolder method like so:
PARA oFormcalled
* This class resets the paths of tables in the data environment
* to CURDIR()
IF PARAMETERS() = 0
RETURN
ENDIF
IF TYPE("oFormcalled.DataEnvironment") = "O"
oEnviron = oFormcalled.DataEnvironment
ELSE
RETURN
ENDIF
IF TYPE("oEnviron") = "O"
nTotMem = AMEMBERS(aMems,oEnviron,2)
WITH oEnviron
IF .AutoOpenTables = .F.
* Check for cursors
FOR i = 1 TO m.nTotMem
IF UPPER(EVAL("."+aMems[m.i]+".BaseClass")) = "CURSOR"
WITH EVAL("."+aMems[m.i])
STORE .Database TO cDB
cDB = SUBSTR(cDB,RAT('\',cDB)+1)
.Database =;
SUBSTR(FULLPATH(cDB),1,RAT('\',FULLPATH(cDB)))+cDB
ENDWITH
ENDIF
ENDFOR
.OpenTables()
ENDIF
ENDWITH
ENDIF
RELEASE oEnviron
and, as you say, set .AutoOpenTables = .F. on all my data environments.
Previous
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