Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generic in BeforeOpenTables in Data Environment
Message
From
07/01/2005 12:02:21
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00974847
Message ID:
00975156
Views:
57
>Hi,
> In VFP8.0 I created a Data Environment class and added my code. Then, I added the class to the DEClass property of my base form class. I closed the base form. Next, I opened one of my forms and found out that the data environment was read only. I couldn't add any tables to the data environment. Also, all of my properties for the data environment were read only. So, I backed out all of my changes to my base form class.
> Next, I tried to add my data environment class to the individual forms. I added the class to the DEClass property of my form. Again, same result, everything was read only and I couldn't add any tables to my data environment.
> What am I doing wrong? Can you explain to me what I have to do? A step-by-step process would be the best solution.
>
> Could you please explain your second approace in a little more detail? Where does the Updatede(this) procedure go? I assume that my routine goes in the Updatede procedure? A step-by-step process would be the best solution.
>
>Thanks,
>Bob

I use this one as I support old versions too. Use at your own risk:
* Assumes all aplication forms are in forms folder
* For forms that have a DE replaces 'ALL' DE method codes with
* custom BeforeOpenTables code
Clear
Clear All
Local lnForms,ix
Local Array arrForms[1]
lnForms = Adir(arrForms, "forms\*.scx")

TEXT to m.lcMethod noshow
PROCEDURE BeforeOpenTables
UpdateDE(this)
ENDPROC
EndText

For ix=1 To lnForms
  Use ('forms\'+arrForms[m.ix,1])
  Locate For Atc('dataenvironment',BaseClass)>0
  If !Eof()
    Replace methods With m.lcMethod
  Endif
  Use
  Compile Form (arrForms[m.ix,1])
Endfor
UpdateDE enables to work with different data paths. However for this sample code do not forget to 'clear all' before modifying forms. What I do is like (command window):

clear all
modi form myForm && do some modifications using base data path which typically is DevPath\data
setDbPath('') && if empty uses the one saved in a table
do form myForm && Check with test data from another data path say \myApp\TestData1
*setdbpath looks like
lparameters tcPath
Public oApp
oApp = NewObject('myApp','main.prg') && oApp sets application data path in init from a table
if !empty(m.tcPath)
* change oApp properties...
endif
* UpdateDE.prg - sample
Lparameters toDE
set exclusive off
*set ... && other sets
Local Array aDEMembers[1]
Local lnMembers,ix,lcMembers
lnMembers = Amembers(aDEMembers,toDE,2)
For ix=1 To m.lnMembers
	With Evaluate('toDe.'+aDEMembers[m.ix])
		If Lower(.BaseClass) == 'cursor' ;
				and Atc(oApp.cAppDBC,.Database) > 0
			.Database = Addbs(oApp.cAppDataPath)+oApp.cAppDBC
		Endif
	Endwith
Endfor
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform