Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataSession and Queries ran from an object???/
Message
From
11/06/2014 11:53:12
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
To
11/06/2014 06:07:40
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Web
Miscellaneous
Thread ID:
01601560
Message ID:
01601669
Views:
32
>My apologies - .AddObject or .AddProperty() makes no difference

In the case you outlined here, it doesn't, because the object is created inside this form('s datasession). But if you pass the object from a different DS and store the reference using .addProperty(), it will continue to execute its code in the DS in which it was created.

>
>* Comparing dataSession ID viewed by an object added to a form either by .AddObject or .AddProperty()
>
>local o
>o = CreateObject('formParent')
>o.Show(1)
>
>define class formParent as Form
>	add object cmdAddObject as cmdAddObject
>	add object cmdAddProperty as cmdAddProperty
>	add object lblDataSession as label with top = 50, autosize =.T.
>	datasession = 2 && private
>	autocenter = .T.
>	procedure init
>		this.AddObject('custAddObject', 'cust') && instance # 1 added by .addObject()
>		this.addProperty('custAddProperty', CreateObject('cust')) && instance # 1 'added' by .addProperty
>		this.lblDataSession.Caption = Textmerge([Datasession ID of form '<<thisForm.Name>>': <<Set("Datasession")>>])
>enddefine
>
>define class cust as Custom && object added to the form either by .AddObject or .AddProperty()
>	procedure dataSessionGet
>		MessageBox(Textmerge([Datasession ID viewed by '<<this.Name>>': <<Set("Datasession")>>]))
>enddefine
>
>define class cmdAddObject as CommandButton
>	caption = 'cmdAddObject'
>	autosize = .T.
>	procedure click
>		local o
>		o = CreateObject('formChild', thisForm.custAddObject)
>		o.show(1)
>enddefine
>
>define class cmdAddProperty as CommandButton
>	caption = 'cmdAddProperty'
>	autosize = .T.
>	left = 100
>	procedure click
>		local o
>		o = CreateObject('formChild', thisForm.custAddProperty)
>		o.show(1)
>enddefine
>
>define class formChild as Form
>	datasession = 2 && private
>	autocenter = .T.
>	add object cmdDataSessionGet as cmdDataSessionGet
>	add object lblDataSession as label with top = 50, autosize =.T.
>	procedure Init(oCust)
>		this.addProperty('oCust', m.oCust)
>		this.cmdDataSessionGet.Caption = this.cmdDataSessionGet.Caption + ' / ' + m.oCust.Name
>		this.lblDataSession.Caption = Textmerge([Datasession ID of form '<<thisForm.Name>>': <<Set("Datasession")>>])
>enddefine
>
>define class cmdDataSessionGet as CommandButton
>	caption = 'cmdDataSessionGet'
>	autosize = .T.
>	procedure click
>		thisForm.oCust.dataSessionGet
>enddefine
>
>
>>Interesting. The .AddObject( ) method is not documented in the standard VFP9 help but it is at http://msdn.microsoft.com/en-us/library/cszcy2ac%28v=vs.80%29.aspx .
>>
>>It looks to me like .AddObject( ) when used with a VFP class, creates a new instance of the class. So, this would not give him any reference to the previous instance on Form A (?)

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform