of_selecttext


pfcdwsrv.pbl   >   pfc_n_cst_dwsrv_find   >   of_selecttext   

Full name pfc_n_cst_dwsrv_find.of_selecttext
Access protected
Extend of integer
Return value integer
Prototype protected function integer of_selecttext(string,long,boolean,string)

Name Datatype
No Data

Name Datatype
li_count integer
li_find_selectedtextlen integer
li_find_startpos integer
li_i integer
li_maskedfind_selectedtextlen integer
li_maskedfind_startpos integer
li_maskedfind_textlen integer
ls_coltype string
ls_editstyle string
ls_find string
ls_maskedfind string

protected function integer of_selecttext (string as_colname, long al_row, boolean ab_matchcase, string as_find);//////////////////////////////////////////////////////////////////////////////
//
//	Function: 		of_SelectText
//
//	Access:  		protected
//
//	Arguments: 		
//	as_colname		The column name.
//	al_row			The row.
//	ab_matchcase	Match case flag.
//	as_find			The find string.
//
//	Returns:  		Integer
//						1 if it succeeds.
//						0 Selection of text is not appropriate.
//
//	Description:  	Selects the appropriate text on the column/row.  Function 
//						takes into consideration the column may be a dropdowndatawindow,
//						dropdownlistbox, or a string with an editmask.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	5.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
//	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.
//
//////////////////////////////////////////////////////////////////////////////

string	ls_find, ls_maskedfind
integer	li_find_startpos, li_find_selectedtextlen
integer	li_maskedfind_textlen, li_maskedfind_startpos, li_maskedfind_selectedtextlen
integer	li_i, li_count
string	ls_coltype, ls_editstyle

//Check required.
If IsNull(idw_requestor) Or Not IsValid(idw_requestor) Then
	Return -1
end If

//////////////////////////////////////////////////////////////////////////////
//Get the current column, columntype, and editstyle
//////////////////////////////////////////////////////////////////////////////
ls_coltype = idw_requestor.describe(as_colname+".coltype")
ls_editstyle = idw_requestor.Describe(as_colname+".Edit.Style")

//////////////////////////////////////////////////////////////////////////////
// If the editstyle of the column is of dddw or ddlb use the LookUpDisplay 
// value.
//////////////////////////////////////////////////////////////////////////////
If ls_editstyle='dddw' or ls_editstyle='ddlb' Then
	If idw_requestor.Describe(as_colname+".ddlb.AllowEdit") = 'yes' or &
		idw_requestor.Describe(as_colname+".dddw.AllowEdit") = 'yes' Then
		//Get the LookUpDisplay value.
		ls_find = idw_requestor.Describe( &
			"Evaluate('LookUpDisplay("+as_colname+")',"+string(al_row)+")")
		//Determine the "LookUpDisplay" starting position and its length.
		If ab_matchcase Then
			li_find_startpos = Pos (ls_find, as_find)
		Else			
			li_find_startpos = Pos (Lower(ls_find), Lower(as_find))
		End If
		li_find_selectedtextlen = Len(as_find)			
		//Select the appropriate portion of the LookUpDisplay value.
		idw_requestor.SelectText(li_find_startpos, li_find_selectedtextlen)		
		Return 1
	End If
End If

//////////////////////////////////////////////////////////////////////////////
// If the column is of character then only select the matching characters 
// within the string.
// Determine the simple find case for a string case.. 
//////////////////////////////////////////////////////////////////////////////
If Left(Lower(ls_coltype),4) = 'char' Then
	//Get complete "Find" string.
	ls_find = idw_requestor.GetItemString(al_row, as_colname)

	//Determine the "Find" starting position and its length.
	If ab_matchcase Then
		li_find_startpos = Pos (ls_find, as_find)
	Else			
		li_find_startpos = Pos (Lower(ls_find), Lower(as_find))
	End If
	li_find_selectedtextlen = Len(as_find)
End If

//////////////////////////////////////////////////////////////////////////////
//	Process strings that have NO editmask
//////////////////////////////////////////////////////////////////////////////
//If a string find, then only select the matching text.
If Left(Lower(ls_coltype),4) = 'char' Then
	If ls_editstyle<>"editmask" Then
		//Select the appropriate text
		idw_requestor.SelectText(li_find_startpos, li_find_selectedtextlen)
		Return 1
	End If
End If

//////////////////////////////////////////////////////////////////////////////
//	Process strings that have an editmask.
//////////////////////////////////////////////////////////////////////////////
//If a string find, then only select the matching text.
If Left(Lower(ls_coltype),4) = 'char' Then
	If ls_editstyle="editmask" Then
		//Get "Masked Find"  and its appropriate length.
		ls_maskedfind = of_GetItem(al_row, as_colname)
		li_maskedfind_textlen = Len(ls_maskedfind)

		//Determine the "Masked Find" starting position and its length.
		li_count = 1
		For li_i = 1 to li_maskedfind_textlen
			If Mid(ls_find, li_count, 1) =  Mid(ls_maskedfind, li_i, 1) Then
				If li_count = li_find_startpos Then
					li_maskedfind_startpos = li_i
				End If
				If li_count = li_find_startpos+li_find_selectedtextlen -1 Then
					li_maskedfind_selectedtextlen = li_i - (li_maskedfind_startpos -1)
					Exit
				End If
				li_count ++							
			End If
		Next

		//Select the appropriate editmasked text.
		idw_requestor.SelectText(li_maskedfind_startpos, li_maskedfind_selectedtextlen)
		Return 1
	End If
End If	

Return 0
end function

     
Name Owner
pfc_n_cst_dwsrv_find.of_find pfc_n_cst_dwsrv_find

     
Name Owner
datawindow.describe datawindow
datawindow.getitemstring datawindow
datawindow.selecttext datawindow
systemfunctions.isnull systemfunctions
systemfunctions.isvalid systemfunctions
systemfunctions.left systemfunctions
systemfunctions.len systemfunctions
systemfunctions.lower systemfunctions
systemfunctions.mid systemfunctions
systemfunctions.pos systemfunctions
systemfunctions.string systemfunctions
pfc_n_cst_dwsrv.of_getitem pfc_n_cst_dwsrv

     
Full name
No Data

     
Name Scope
No Data