Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can i convert a from to prg with its private DE ?
Message
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00454478
Message ID:
00455436
Views:
31
Clarification

I posted that you could use AddObject/NewObject to add the Dataenvironment. This throws an error in VFP. In order to get this to work, you need to use AddProperty. Ex.
Form Load
oDE = newobject("DE","test.prg")
THISFORM.AddProperty("Dataenvironment", oDE)

Form Destroy
if upper(pemstatus(THIS,"Dataenvironment",3)) = "OBJECT" then
	THIS.RemoveObject("Dataenvironment")
else
	THIS.Dataenvironment = .NULL.
endif
The Destroy code is generic to both form classes with manually instantiated Dataenvironments and forms created from those classes with default Dataenvironments.

>No it won't. In order to do that, instead of creating a separate variable for the DE, use the form variable and AddObject the DE class to it. When the form is destroyed, the associated object should be destroyed. However, if there is a problem, you may have to explicitly release the DE object in the Destroy of the form to avoid dangling object references.
>
>Form.Load
>THISFORM.AddObject("oDE","DE")
>
>Form.Destroy
>THISFORM.RemoveObject("oDE")
>
>>Will This behave like the Private DE that as designed in from visual designer.
>>That whenever I change the form the DE is seleted.
>>
>>
>>>>>can i convert a from to prg with its private data environment.
>>>>>Rajesh
>>>>Sure you can.
>>>
>>>Highly informative! ;-)
>>It was lame (appologies):
>>Public oForm,oDE
>>oForm=createobject('Form')
>>oDE=createobject('DE')
>>oDE.OpenTables
>>select freetable
>>messagebox(alias())
>>oDE.CloseTables
>>
>>Define class DE as DataEnvironment
>>Add object oFREETABLE as cursor
>>oFREETABLE.Alias="freetable"
>>oFREETABLE.Cursorsource="c:\data\freetable.dbf"
>>Enddef
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform