Article ID 2363 Article Title HOWTO: Enumerate all child objects of a (db)View Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2363 KBase Category Visual DataFlex Date Created 03/11/2008 Last Edit Date 03/11/2008
Article Text
QUESTION:
How can I scan all the objects contained in a dbView, and query a property
of each object?
SOLUTION:
Add this code to your parent object (or class of that parent) and you can enumerate all child objects of that parent object. It has been tested on a dbView and a dbTabPage.
Function IsChildOfSelf Handle hoId Returns Boolean
Repeat
Get Parent of hoId to hoId
Until (hoId = Self or hoId = 0 or hoId = Desktop)
Function_Return (hoId = Self)
End_Function
Function ChildObjects Returns Handle[]
Handle[] hoChildren
Handle hoID
Integer iCounter
Boolean bIsChild
For iCounter from 1 to Total_Objects
Get Object_Id of iCounter to hoID
If (hoId > 0) Begin
Get IsChildOfSelf hoID to bIsChild
If (bIsChild) Begin
Move hoID to hoChildren[SizeOfArray (hoChildren)]
End
End
Loop
Function_Return hoChildren
End_Function
You can use it with:
Procedure ShowAllChildren
Handle[] hoChildren
Integer iElements iElement
Get ChildObjects to hoChildren
Move (SizeOfArray (hoChildren)) to iElements
Decrement iElements
For iElement from 0 to iElements
Showln "ID: " hoChildren[iElement] " Name=[" (Name (hoChildren[iElement])) "]"
Loop
End_Procedure
On_Key Key_Alt+Key_F11 Send ShowAllChildren
Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu
Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2024 Data Access Corporation. All rights reserved.
The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.