Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Class Hierarchy Question
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01035408
Message ID:
01035575
Views:
10
John,

You are not using VFP9 as you stated, are you? In VFP9 the first two class definitions you posted are illegal, in particular use of NEWOBJECT() in a property definition. It generates an error 'Statement is not valid in a class definition'.
Here's implemetation that works
DEFINE CLASS theFirst as Custom
	oSecond = Null
	myVal = Null

	PROCEDURE Init
		This.oSecond = NEWOBJECT("theSecond")
		This.myVal = this.oSecond.myVal
	ENDPROC
ENDDEFINE

DEFINE CLASS theSecond as Custom
	oThird = Null
	myVal = Null

	PROCEDURE Init
		This.oThird = NEWOBJECT("theThird")
		This.myVal = this.oThird.myVal
	ENDPROC
ENDDEFINE

DEFINE CLASS theThird as Custom
	myVal = "1234"
ENDDEFINE


>
>Thanks for the advice, but this does not work as expected. Below is a sample.
>
>"theFirst" implements "theSecond" which implements "theThird" (I know, I know, I over did it!). theThird's "myVal" property is passed up the line.
>
>
>DEFINE CLASS theFirst as Custom
>oSecond=NEWOBJECT("theSecond")
>myVal=this.oSecond.myVal
>ENDDEFINE
>
>DEFINE CLASS theSecond as Custom
>oThird=NEWOBJECT("theThird")
>myVal=this.oThird.myVal
>ENDDEFINE
>
>DEFINE CLASS theThird as Custom
>myVal="1234"
>ENDDEFINE
>
>
>So I instantiate theFirst and access members:
>
>
>oFirst=NEWOBJECT("theFirst","theClass.prg")
>? oFirst.myVal                             (prints "1234")
>? TYPE("oFirst.oSecond")                   (prints "O")
>? TYPE("oFirst.oSecond.oThird")            (prints "U")
>oSecondAndAHalf=oFirst.oSecond
>? oSecondAndAHalf.myVal                    (prints "1234")
>? TYPE("oSecondAndAHalf.oThird")           (prints "O")
>? TYPE("oSecondAndAHalf.oThird.myVal")     (prints "U")
>
>
>...you get the idea.
>
>If I try:
>
>
>? oFirst.oSecond.myVal
>
>
>I get an "Unknown member OSECOND" error.
>
>So what the hell am I missing here?
>
>Thanks!
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform