Forum Post: How to make a good Search function

Status
Not open for further replies.
L

lefty1984

Guest
hi, 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.

Continue reading...
 
Status
Not open for further replies.
Top