|
of_searchchild
|
|
Full name
|
pfc_n_cst_tvsrv.of_searchchild
|
Access
|
protected
|
Extend of
|
long
|
Return value
|
long
|
Prototype
|
protected function long of_searchchild(string,any,long,integer,boolean,boolean)
|
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
// 6.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
// 7.0 Fix to work when tree is empty
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 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
If ll_qposition > Upperbound(il_queue) Then Return -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 itv_requestor.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 itv_requestor.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 = itv_requestor.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 = itv_requestor.FindItem(NextTreeItem!, ll_child)
Loop
ll_qposition++
Loop until ll_qposition > upperbound(il_queue)
Return 0
end function
Name
|
Owner
|
treeview.finditem |
treeview
|
treeview.getitem |
treeview
|
systemfunctions.upperbound |
systemfunctions
|
pfc_u_tvs.pfc_searchcompare |
pfc_u_tvs
|