How to make a good Search function

Posted by lefty1984 on 25-Sep-2014 10:09

How can i make a good search function to search some data in a browse.
Now I have used a fill-in and when I type text the code below directly search into the browse. Now I would like to use a function that I make once and then can invoke from different procedures.
Do you have any idea how I can do that well. The code below is very old but i dont know how to make a search field like below.

procedure relres:
zoek = "".
zoek1 = "".
OPEN query browse-3 for each register.personeel no-lock use-index i_inlog_code indexed-reposition.
view frame frame-bbb IN WINDOW window-1.
find first register.personeel use-index i_inlog_code no-error.
current-record = recid(personeel).
if available(personeel) then current-record = recid(personeel).
REPOSITION browse-3 TO RECID Current-Record.
Method-Return = browse-3:SELECT-FOCUSED-ROW().     
update zoek with no-label frame frame-bbb editing:
  readkey.   
  ac = length(zoek1).
  if keyfunction(lastkey) = "return" then do:
   zoeknum = 0.
   zoeknum = INT(zoek1) NO-ERROR.
   IF INT(zoeknum) <> 0 THEN FIND register.personeel NO-LOCK WHERE register.personeel.inlog_code = INT(zoek1).
   IF available(personeel) THEN leave.
  end. 
  if keyfunction(lastkey) = "end-error" then do:
   leave.
  end. 
  if keyfunction(lastkey) = "cursor-down" then do:
   method-return = browse-3:select-next-row().
   zoek = register.personeel.achternm.
   zoek1 = "".
   display zoek with frame frame-bbb.
   zoek:cursor-offset = 1.
  end. 
  if keyfunction(lastkey) = "cursor-up" then do:
   method-return = browse-3:select-prev-row().
   zoek1 = "".
   zoek = register.personeel.achternm.
   display zoek with frame frame-bbb.
   zoek:cursor-offset = 1.
  end. 
  if keyfunction(lastkey) = "backspace" then do:
   ac = length(zoek1) - 1.
   zoek1 = substring(zoek1,1,ac).
   apply lastkey.
   current-record = recid(personeel).                 
   find first register.personeel use-index iachternaam where register.personeel.achternm begins zoek1 no-error.
   if available(personeel) then current-record = recid(personeel).
   REPOSITION browse-3 TO RECID Current-Record.
   Method-Return = browse-3:SELECT-FOCUSED-ROW().
   display "               " @ zoek with frame frame-bbb.
   display zoek1 @ zoek with frame frame-bbb.
  end.
  else do:   
   letter = chr(lastkey).
   if index("1234567890 .,-ABCDEFGHIJKLMNOPQRSTUVWXYZ",caps(letter)) > 0 then do:
    zoek1 = zoek1 + letter.
    current-record = recid(personeel).                 
    find first register.personeel use-index iachternaam where register.personeel.achternm begins zoek1 no-error.
    if available(personeel) then current-record = recid(personeel).
    REPOSITION browse-3 TO RECID Current-Record.
    Method-Return = browse-3:SELECT-FOCUSED-ROW().
    apply lastkey.
    display "               " @ zoek with frame frame-bbb.
    display zoek1 @ zoek with frame frame-bbb.
   end. 
  end.
end.

Posted by lefty1984 on 09-Oct-2014 04:49

Found the solution for a good search

All Replies

Posted by Thomas Mercer-Hursh on 25-Sep-2014 10:15

On the right end of the bottom row in the rich code editor there is a button which will allow you to paste in code that will get displayed in a readable format.  I suggest that as the first step.

Posted by James Palmer on 25-Sep-2014 10:18

I would suggest looking at using dynamic queries to make the code reusable.

Posted by lefty1984 on 25-Sep-2014 13:46

cant set my code as code only as text like this.

Posted by lefty1984 on 25-Sep-2014 13:46

i will look at dynamic queries. many thanks.

Posted by Thomas Mercer-Hursh on 25-Sep-2014 14:26

It is the button that looks like a highlighter pen.  Hover over it and it will say "Insert code using Syntaxhighlighter".  Click on it and it will pop up a box into which you can paste your code.

Posted by Dileep Dasa on 26-Sep-2014 00:17

Here is a pictorial representation of what Thomas said:

community.progress.com/.../8723.aspx

Posted by lefty1984 on 30-Sep-2014 09:11

Found it, in IE it wasnt visable :)

Posted by lefty1984 on 09-Oct-2014 04:49

Found the solution for a good search

This thread is closed