Hello,
I created a script for a text search in my application, based on the function tbl.fetch_loc_next(TextToLocate) as per code below.
It works great for searching for text through a file. If the person selects "No" when requested to search again, a new search can be started successfully. However if the script gets to the "End of File" routine, then a new search cannot be initiated until the form is closed and reloaded. Using the Debug function shows that the script does not execute properly anymore and am stumped to figure out why.
Any help and suggestions on solving this are much appreciated.
I created a script for a text search in my application, based on the function tbl.fetch_loc_next(TextToLocate) as per code below.
It works great for searching for text through a file. If the person selects "No" when requested to search again, a new search can be started successfully. However if the script gets to the "End of File" routine, then a new search cannot be initiated until the form is closed and reloaded. Using the Debug function shows that the script does not execute properly anymore and am stumped to figure out why.
Any help and suggestions on solving this are much appreciated.
Code:
'Setting Variables and opening File '---------------------------------- dim pObj as p pObj = topparent.this dim TextToLocate as c dim searchagain as c dim locateFlag as l locateFlag = .F. DIM SHARED searchtext_result as N DIM SHARED searchtext_YES_Button as L DIM SHARED searchtext_NO_Button as L searchtext_YES_Button = .F. searchtext_NO_Button = .F. dim tbl as p tbl = pObj.table_get() invert(recno()) topparent.fetch_first() 'Asking what Text to locate '-------------------------- TextToLocate = ui_get_text("Locate What","Select Text to locate") if TextToLocate = "" then ui_msg_box("Error","You must specify non-blank text to Locate.",UI_STOP_SYMBOL) end end if 'debug(1) 'Looking for the Text '-------------------- while .not. tbl.fetch_eof() locateFlag = tbl.fetch_loc_next(TextToLocate) if locateFlag = .t. then pObj.resynch() title_var = "Search again" message_text_var = "Search again for " + TextToLocate searchtext_result=ui_msg_box(title_var,message_text_var,UI_YES_NO+ UI_FIRST_BUTTON_DEFAULT+ UI_QUESTION_SYMBOL) SELECT CASE searchtext_result = UI_YES_SELECTED searchtext_YES_Button= .t. locateFlag = .F. CASE searchtext_result = UI_NO_SELECTED searchtext_NO_Button= .t. end END SELECT else ui_msg_box("Note","Text not found.",UI_INFORMATION_SYMBOL) exit while end end if end while
Comment