of_finditem


pfcmain.pbl   >   pfc_u_tv   >   of_finditem   

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

Name Datatype
No Data

Name Datatype
li_next Integer
ll_handle Long
ll_parent Long
ll_queue Long[]
ltvi_item Treeviewitem

public function long of_finditem (string as_attribute, any aa_target, long al_begin, integer ai_level, boolean ab_respectcase, boolean ab_fullcompare);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_FindItem
//
//	Access:  public
//
//	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 matches the target.  Returns 0
//					if not found, -1 if an error occurrs.
//
//	Description:	Search for an item in the TreeView.  This function calls of_SearchChild
//						to search for the target in either the Label or Data attribute
//						of the TreeView items.  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_next
Long				ll_handle, ll_parent, ll_queue[]
Treeviewitem	ltvi_item

If IsNull(as_attribute) or IsNull(al_begin) or IsNull(ai_level) or &
	IsNull(ab_respectcase) or IsNull(ab_fullcompare) Then Return -1
If (al_begin < 0) or (ai_level < 0) or (as_attribute = "") Then Return -1

// this could be a potentially long operation
SetPointer(hourglass!)

// reset the queue
il_queue = ll_queue

// Initialize the tree queue
If al_begin = 0 Then
	// search the whole tree, look for multiple nodes on level 1
	ll_handle = this.FindItem(RootTreeItem!, 0)
Else
	// start at the beginning position and search the children from that point down
	// add handle to queue
	li_next = upperbound(il_queue) + 1
	il_queue[li_next] = al_begin
	// search for siblings
	ll_handle = this.FindItem(NextTreeItem!, al_begin)
End IF

// add siblings to the queue
Do While ll_handle > 0
	// add handle to queue
	li_next = upperbound(il_queue) + 1
	il_queue[li_next] = ll_handle
	ll_handle = FindItem(NextTreeItem!, ll_handle)
Loop

Return of_SearchChild(as_Attribute, aa_Target, al_begin, ai_Level, ab_RespectCase, ab_FullCompare)

end function

     
Name Owner
pfc_u_tv.of_FindItem pfc_u_tv
pfc_u_tv.of_FindItem pfc_u_tv
pfc_u_tv.of_FindItem pfc_u_tv
pfc_u_tv.of_FindItem pfc_u_tv
pfc_u_tv.of_findfirstitemlevel pfc_u_tv
pfc_u_tv.of_getitemfordata pfc_u_tv

     
Name Owner
treeview.finditem treeview
systemfunctions.isnull systemfunctions
systemfunctions.setpointer systemfunctions
systemfunctions.upperbound systemfunctions
pfc_u_tv.of_searchchild pfc_u_tv

     
Full name
No Data

     
Name Scope
No Data