Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exclude VCX from a project
Message
 
 
To
07/07/2003 15:19:32
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00806761
Message ID:
00808411
Views:
18
Peter,
#2 is more complicated than I thought or its documentation is worse than I thought. ;-)

#2 really means that if you have classes of the same name in different class libraries or procedures, the definition that was loaded into memory first is used. Here is an example:
Proc1.Prg
define class sesclass as session
procedure DisplayMessage
? 'This is from Proc1'
endproc
enddefine

Proc2.Prg
define class sesclass as session
procedure DisplayMessage
? 'This is from Proc2'
endproc
enddefine
Then in your program you have something like this:
local lox, loy
set procedure to proc1
lox = createobject('sesclass')
lox.DisplayMessage()
set procedure to proc2 additive
loy = createobject('sesclass')
loy.DisplayMessage()
You will see the message 'This is from Proc1' twice. The reason is that the class definition for Sesclass was loaded first using Proc1.prg.

You can avoid this by overwriting the SET CLASSLIB or SET PROCEDURE paths with another SET command and not specifying the ADDITIVE keyword. Or you could use the NewObject function or method. This command internally issues a new SET CLASSLIB or SET PROCEDURE command with the specified class definition first.

HTH.

>Hi Larry,
>
>I tried to see how #2 works but so far I cannot make it work. I put the following coding in a form init():
>
>set classlib to myclasslib
>ocreatetxt = createobject("mytxt") && mytxt is a class in myclasslib.vcx
>set classlib to myotherclasslib
>this.addobject("oaddtxt", "mytxt")
>this.oaddtxt.visible = .t.
>
>or
>
>onewtxt = newobject("mytxt", "myclasslib")
>this.addobject("oaddtxt", "mytxt")
>this.oaddtxt.visible = .t.
>
>Both codings will generate the error "Class defintion MYTXT is not found." when trying to execute the this.addobject statement.
>
>
>Note: I have also added the object mytxt to the form from Form Designer. I guess this should also load the class into the memory. Am I right?
>
>
>Thank you,
>
>Peter
Larry Miller
MCSD
LWMiller3@verizon.net

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

Click here to load this message in the networking platform