datawindow text search(

Posted on 2006-05-29
Last Modified: 2013-12-26
dear gafoor with refrence to one other question u provided a userobject for text serach on datawindow can u please mail that to me i have an urgent requirement or if any body else can help me pls.
thanks in advance
GHulam Rabbani
my email is
Question by:SHFDEV
    1 Comment
    LVL 18

    Accepted Solution


    is this what ur looking for...

    //////////////////////////// code starts here//////////////////////

    $PBExportComments$UserObject to FastFind Data in Datawindows
    global type sle_uo_fast_find from singlelineedit
    end type
    end forward

    global type sle_uo_fast_find from singlelineedit
    integer width = 530
    integer height = 96
    integer textsize = -8
    integer weight = 400
    fontcharset fontcharset = ansi!
    fontpitch fontpitch = variable!
    fontfamily fontfamily = swiss!
    string facename = "MS Sans Serif"
    long textcolor = 33554432
    borderstyle borderstyle = stylelowered!
    event ue_edit_change pbm_enchange
    event ue_enter pbm_keydown
    end type
    global sle_uo_fast_find sle_uo_fast_find

    type variables
    Boolean          ib_fastfind = True, ib_quote[], ib_repeat, ib_select = True, ib_pfc
    Boolean          ib_MatchCase
    Integer          ii_colcount, ii_found
    String          is_colname[], is_start_any[]
    Datawindow     idw_Ref
    end variables

    forward prototypes
    public subroutine of_setfastfind (boolean ab_choice)
    public function integer of_registercol (string as_colname, string as_start_any)
    public subroutine of_setrowselect (boolean ab_rowselect)
    public function boolean of_setdw (ref datawindow adw_ref)
    public subroutine of_setmatchcase (boolean ab_matchcase)
    end prototypes

    event ue_edit_change;String     ls_text, ls_find
    Integer     li_len, li_i, li_start

    ls_text = This.Text
    li_len = Len(ls_text)

    If not ib_MatchCase Then ls_text = Upper(ls_text)

    If li_len <= 0 Then
         ii_found = 0
         ib_repeat = False
    //     Return
    End If

    // Generate the Find Expression
    For li_i = 1 To ii_colcount
         If is_start_any[li_i] = 'start' Then     // Look for entered text starting with
    //          If ib_quote[li_i] Then
              If ib_MatchCase Then
                   ls_find     =     ls_find + "Left(String(" + is_colname[li_i] + ")," +&
                                       String(li_len) + ") = '" + ls_text + "' Or "              
                   ls_find     =     ls_find + "Left(Upper(String(" + is_colname[li_i] + "))," +&
                                       String(li_len) + ") = '" + ls_text + "' Or "
              End If
    //          ElseIf IsNumber(ls_text) Then
    //               ls_find     =     ls_find + "Left(Upper(String(" + is_colname[li_i] + "))," +&
    //                                   String(li_len) + ") = " + ls_text + " Or "
    //          End If
         Else     // Look for entered text anywhere in the col data
              If ib_MatchCase Then
                   ls_find     =     ls_find + "Pos(String(" + is_colname[li_i] + "), '" +&
                                       ls_text + "', 1) > 0 Or "              
                   ls_find     =     ls_find + "Pos(Upper(String(" + is_colname[li_i] + ")), '" +&
                                       ls_text + "', 1) > 0 Or "
              End If
         End If

    // Trim the find expression to remove the " Or " sequence at the end.
    ls_find = Left(ls_find, Len(ls_find) - 4)

    If ib_repeat Then
         li_start = ii_found
         li_start = 0
    End If
    //MessageBox("find string", ls_find)
    ii_found     =     idw_ref.Find(ls_find, li_start + 1, idw_ref.RowCount())

    // If row is found, scroll to it
    If ii_found > 0 Then
         If ib_Select Then
              // Check if this is a pfc dw and if the row select service is turned on
              If ib_pfc Then
                   idw_Ref.Event RowFocusChanged(ii_found)
                   idw_Ref.SelectRow(0, False)
                   idw_Ref.SelectRow(ii_found, True)
              End If
         End If
    End If
    end event

    event ue_enter;If Key = KeyEnter! Then
         ib_repeat = True
         This.Event ue_Edit_Change()
         ib_repeat = False
    End If
    end event

    public subroutine of_setfastfind (boolean ab_choice);ib_FastFind = ab_choice
    end subroutine

    public function integer of_registercol (string as_colname, string as_start_any);String     ls_coltype
    Boolean     lb_quote

    // Possible Values for as_start_any are 'start', 'any' meaning, search for the reqd text
    // from the start or anywhere in between

    // There is no Reference to the Search DW, Call of_SetDW() first.
    If Not IsValid(idw_Ref) Then Return -1

    ls_coltype = Lower(Left(idw_ref.Describe(as_colname + ".ColType"),4))

    Choose Case ls_coltype
         Case 'char', 'date'
              lb_quote = True
         Case 'numb', 'long', 'int', 'deci', 'real'
              lb_quote = False
         Case Else
              Return -1
              // Either Invalid Column OR UnSupported Datatype.
              // This object can be changed to include required datatypes.
    End Choose

    ii_colcount ++

    is_colname[ii_colcount] = Lower(as_colname)
    ib_quote[ii_colcount] = lb_quote
    is_start_any[ii_colcount] = Lower(as_start_any)

    Return ii_colcount
    end function

    public subroutine of_setrowselect (boolean ab_rowselect);ib_select = ab_rowselect
    end subroutine

    public function boolean of_setdw (ref datawindow adw_ref);Boolean lb_return

    If IsValid(adw_ref) Then
         idw_Ref = adw_ref
         ib_pfc = (idw_Ref.TriggerEvent('pfc_descendant') = 1)
         lb_Return = True
    End If

    Return lb_Return

    end function

    public subroutine of_setmatchcase (boolean ab_matchcase);ib_MatchCase = ab_matchCase
    end subroutine

    on sle_uo_fast_find.create
    end on

    on sle_uo_fast_find.destroy
    end on

    event constructor;// AUTHOR:               gaf
    // OBJECT NAME:     sle_uo_fast_find
    // PURPOSE:               To search through datawindow columns for a text/number/date
    //     HOW TO USE:      1. Place this SLE userobject in any window/userobject
    //                              2. In THIS object's constructor (recommended) event...
    //                                        of_SetDW(search_dw)
    //                                        of_RegisterCol(column_name, search_type)
    //                                        of_SetRowSelect(boolean)
    //                              3. Call of_RegisterCol any number of times to include all
    //                                   searchable columns
    //                              4. The Search_Type can be - 'START' or 'ANY'
    //                              5. 'START' will search for data (in columns) that start with the text entered
    //                              6.     'ANY' will search for the entered text anywhere in column data
    //                              7. If the required text appears more than once in all rows, then hit
    //                                   'enter' key to loop through all occurences.
    //                              8. of_SetRowSelect() actually determines whether to select the row if the
    //                                   search criteria matches.
    //     LAST REVISED:     May 9, 2003 -

    end event

    ///////////////////code ends here/////////////////////

    Please refer the following links...


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deletiā€¦
    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now