Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Paths in the data environment
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00032305
Message ID:
00032820
Vues:
42
>>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform