PMFJI,
I am slightly mystified by how the whole init thing works. One would assume that the container doesn't exist until all it's children have instanciated and the containers init has fired (if I look in the debugger while stepping through the init sequence the parent is not there). But it doesn't work that way.
Tom can do what he was attempting, I think the syntax was wrong though, it should be
IF PEMSTATUS(This.Parent.Parent, <b>'DisplayValue'</b>, 5)
added code here
ENDIF
This will return true if the grandparent contains the PEM from this.init. I tested and does work. But I would think it shouldn't for the same reason Tom stated, 'The form has instanciated'.
Care to DeMystify this behaviour?
>>I have created a master class that adds another class to
>>it via ADDOBJECT(). The master class was added to a form
>>so that when the program is started from the form the lowest
>>level class needs to check a property on the form as follows:
>>
>>This.Parent.Parent.cmbFileID.DisplayValue
>>
>>That is, I have the following hierachy (sp?):
>>
>>1. Form
>> 2. MainClass
>> 3. SubClass
>>
>>Now, I would also like to run the code simply by instatiating
>>the MainClass (no form used). Therefore, I need to conditionally
>>get the form value only if it exists.
>>
>>So in the INIT() of the subclass I thought the following code
>>would work:
>>
>>IF PEMSTATUS(This.Parent.Parent,Class,5)
>> added code here
>>ENDIF
>>
>>The PEMSTATUS() call fails since the form does not exist. The
>>actual error is Parent is not an object.
>>
>>How can I conditionally check to see if the code was kicked off
>>from the mainclass or the form?
>
>IF TYPE("THIS.Parent.Parent.Name") = "C"
>
>*does a grandparent pbject exist?
>ENDIf
Roi
'MCP' Visual FoxPro
In Rome, there was a poem.
About a dog, who found two bone.
He lick the one, he lick the other.
He went pyscho, he drop dead!