Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine the object existed
Message
From
01/09/1999 06:34:25
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
31/08/1999 23:45:05
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00260014
Message ID:
00260049
Views:
15
>Hi,
> I have a control (mycontrol) that allocated in myform.pageframe.page1.container
>How could I determine that mycontrol is a "child" in my form?
>I tried to use sys(1272) and PEMSTATUS(), but I don't get what I I need.
>Sys(1272) return the same thing I passed to it and PEMSTATUS only check for the top 1st level of child and not go deep. How could I implement this without having to go through each of the controls?
>
>?SYS(1272,myform.pageframe.page1.container.mycontrol)
>
>Thank you
John,
Question is not clear. Referring to your title and sample code ?sys(1272...) I assume you know the reference but want to check existence :

lControlExist = ( type("myform.pageframe.page1.container.mycontrol") = "O" ;
and !isnull(myform.pageframe.page1.container.mycontrol) )

You could use sys(1272) to get object hierarchy. ie:
? sys(1272, this)
lcObjRef = stuff(sys(1272, this),1,at(".",sys(1272, this))-1, "thisform")
&lcObjRef..refresh 

*Also another usefull one is "parent"
* Say you know your object is on a page but don't know 
* how much deep in hierarchy there and want to get a reference to its page

? GetContRef(myform.pageframe.page1.container.mycontrol, "Page")
* Using recursion
procedure getContRef
lparameters toObject, tcContainerBaseClass
if !toObject.baseclass = tcContainerBaseClass
  return getContRef(toObject.Parent,tcContainerBaseClass)
else
  return toObject
endif

* Plain version
procedure GetContRef
lparameters toObject, tcContainerBaseClass
do while toObject.baseclass # tcContainerBaseClass
  toObject = toObject.Parent
enddo
return toObject
Pls note that GetContRef doesn't check if it's valid what you request. If you call if with like :
? GetContRef(myform.pageframe.page1.container.mycontrol, "Container")
and doesn't have a Conatiner in hierarchy or doesn't even have a parent it would bomb.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform