Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strored Paths
Message
From
25/06/2000 08:41:34
 
 
To
24/06/2000 19:48:48
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00384317
Message ID:
00384396
Views:
23
Here is the code to do what you want...

LOCAL lcDataPath, lcOldPath
LOCAL ARRAY laObjectList[1,1]
IF TYPE("oApp") = "O" && We are running the form from the application
* Check to see if there is a data path stored in the app
IF NOT EMPTY(oApp.cDataPath)
This.cDataPath = oApp.cDataPath
* Make a list of all the cursors in the Data Environment
= AMEMBERS(laObjectList,ThisForm.DATAENVIRONMENT,1)
= ASORT(laObjectList, 2)

* Plug in our data path
IF ASCAN(laObjectList, "Object") > 0
nStartpos=ASUBSCRIPT(laObjectList, ASCAN(laObjectList, "Object"),1)
FOR I = nStartpos TO ALEN(laObjectList,1)
IF laObjectList(I,2) = "Object"
cObjClass = "ThisForm.DATAENVIRONMENT." + laObjectList(I,1)+".class"
IF EVALUATE(cObjClass)="Cursor"
cObjName="ThisForm.DATAENVIRONMENT." ;
+ laObjectList(I,1)+".DATABASE"
Data_Name=EVALUATE(cObjName)
NewDataPath = ThisForm.cDataPath + '\' + ALLTRIM(SUBSTR(Data_Name, RAT("\",Data_Name)+1))
oRef = EVALUATE( "ThisForm.DATAENVIRONMENT."+laObjectList(I,1) )
*Modify the Database property with the new path
oRef.DATABASE = NewDataPath
ENDIF
ELSE
EXIT
ENDIF
ENDFOR
ENDIF
ENDIF
ENDIF
<\PRE>
>On my development machine I typically have a data directory set on the path for each project. I also have several sets of data (user data) in other directories, either local or on the network. It has always bugged me that I could not access these sets of data, running the main form from the command line, or running the .exe for the app - it always accessed the data in the original test data directory.
>Yes, I know that's due to the path being stored, and never a problem on a production machine because we set a path, and the stored path directory does not exist.
>One school of thought suggested that problem was the path stored in the .DBC, but this turns out not to be so. Short answer has been to rename the the test directory whenever I want to work on another set of data. That is, until while in a user directory, I made a change to a form, which called a pick list, and the pick list failed to work.
>Turns out that saving the change stored the new path for the database in the calling form. Easily resolved.
>I know there are arguments for and against storing paths, but is there a way to turn it off? It may be 'by design', but it creates a minefield.
Previous
Reply
Map
View

Click here to load this message in the networking platform