of_searchchild


pfcmain.pbl   >   pfc_u_tv   >   of_searchchild   

Full name pfc_u_tv.of_searchchild
Access protected
Extend of long
Return value long
Prototype protected function long of_searchchild(string,any,long,integer,boolean,boolean)

Name Datatype
No Data

Name Datatype
li_Level Integer
li_next Integer
ll_child Long
ll_Handle Long
ll_qposition Long
ltvi_Item TreeViewItem

protected function long of_searchchild (string as_attribute, any aa_target, long al_begin, integer ai_level, boolean ab_respectcase, boolean ab_fullcompare);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_SearchChild
//
//	Access:  protected
//
//	Arguments:
//	as_Attribute				The attribute of the TreeView item to search ("Label", 
//									or "Data")
//	aa_Target					A variable of type Any containg the search target.
//	al_Begin					The handle of the TreeView item to begin searching, if
//									0 entire tree will be searched.
//	ai_Level					The level to search, if 0 entire tree will be searched.
//	ab_RespectCase			True - search is case sensitive,
//									False - search is not case sensitive.  Only used if the target
//									is a string.
//	ab_FullCompare			True - Label or Data and Target must be equal,
//									False - Label or Data can contain Target (uses POS() function).
//									Only used if the target is a string.
//
//	Returns:		Long
//					The handle of the item whose Label or Data matches the target.  Returns 0
//					if not found, -1 if an error occurrs.
//
//	Description:	Search for the target in either the Label or Data attribute of the TreeView 
//						items..  This function is called by of_FindItem.  It will use the 
//						pfc_searchcompare event to actually perform the comparison.  Override 
//						this event if another comparison is desired.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	5.0   Initial version
//	6.0.01	Rewrite to be non-recursive to avoid stack overflow errors.  Use a queue 
//				to simulate recursion in a level centered traversal
//
//////////////////////////////////////////////////////////////////////////////
//
//	Copyright © 1996-1999 Sybase, Inc. and its subsidiaries.  All rights reserved.
//	Any distribution of the PowerBuilder Foundation Classes (PFC)
//	source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

Integer				li_Level, li_next
Long					ll_Handle, ll_child, ll_qposition
TreeViewItem		ltvi_Item

ll_qposition = 1

DO
	ll_handle = il_queue[ll_qposition]
	
	// should not put invalid items in the queue, but check it anyway and also get the level info
	If GetItem(ll_handle, ltvi_Item) = -1 Then Return -1
	li_level = ltvi_Item.Level

	// make the comparison
	If ai_Level = 0 Or ai_Level = li_Level Then
		If Trigger Event pfc_searchcompare(ll_handle, as_Attribute, aa_Target, ab_RespectCase, &
															ab_FullCompare) Then Return ll_handle
	Else
		// queue is populated in level order, so when the current level is greater than the level
		// to search in, we did not find the item.
		If li_level > ai_level then Return 0
	End If

	// match was not found, so add this item children to the end of the queue
	ll_child = FindItem(ChildTreeItem!, ll_handle)
	Do While ll_child > 0
		// add handle to queue
		li_next = upperbound(il_queue) + 1
		il_queue[li_next] = ll_child
		ll_child = FindItem(NextTreeItem!, ll_child)
	Loop

	ll_qposition++

Loop until ll_qposition > upperbound(il_queue)

Return 0

end function

     
Name Owner
pfc_u_tv.of_finditem pfc_u_tv

     
Name Owner
treeview.finditem treeview
treeview.getitem treeview
systemfunctions.upperbound systemfunctions
pfc_u_tv.pfc_searchcompare pfc_u_tv

     
Full name
No Data

     
Name Scope
No Data