Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Distribution Problems
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00098844
Message ID:
00099283
Views:
28
Hi Bob, here is the Load Event from my base data form class. It calls another object called app.fileinit to get the "real" path of the data. (It's all very complicated isn't it). The fileinit module use forcepath to force the path of the data file from what it is in the DE to a path stored against the table name in a table called Fileinit. So if Fileinit.dbf has "F:\MYDATA\" stored against say "NAMES.DBF" and the DE has "C:\DEVLOPMENT\MYCUST\DATA\NAMES.DBF" , this load event will change the DE path to "F:\MYDATA\NAMES.DBF", before the tables are loaded. Note that you've got to turn AutoOpenTables OFF in the DE for this to work.
DoDefault()

WITH THISFORM
	* if there is a dataenvironment set the aliascurrent to InitialSelectedAlias
	IF TYPE(".Dataenvironment.Name") = "C"
		LOCAL oDE, oObj, nIdx, cObjName
		LOCAL ARRAY a_Obj[1], a_Files[1], a_tag[1]

		oDE= THIS.Dataenvironment
		IF EMPTY(.aliasCurrent) AND ! EMPTY(oDE.InitialSelectedAlias)
			.aliasCurrent= UPPER(oDE.InitialSelectedAlias)
		ENDIF

		IF ! oDE.AutoOpenTables
			* assumes app.dirData is set and/or fileinit specifier

			nObj= AMEMBERS(a_Obj, .Dataenvironment, 2)
			FOR EACH cObjName IN a_Obj
				oObj= EVALUATE(".Dataenvironment."+ m.cObjName)
				IF oObj.BaseClass = "Cursor"
					* Is the alias in fileInit?
					IF EMPTY(oObj.Database)
						* If a free table adjust the cursorsource
						oObj.CursorSource= app.fileinit.fileName(oObj.alias)
					ELSE
						* otherwise adjust the database source
						oObj.Database= app.fileinit.fileName(oObj.alias, .T.)
					ENDIF
				ENDIF
			ENDFOR
			oDE.OpenTables()
		ENDIF	
	ENDIF		&& Dataenvironment
ENDWITH
>Dave,
>
>Can you please expand on this? I am assuming you use the INIT method of
>the Data Environment to call the Forcepath() function??
>
>Thanx!
>Bob :-)
>
>>Hi Ian,
>>In addition to what others have said, you will find that the full path to the data in any Form.DataEnvironment during development is used in your distributable. I have modified my base form class to reset all data paths in the DE. (I use the ForcePath() function in Foxtools during this process)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform