name Regexp group "&Learning"; filename = ""; connection = ""; file = false; sub getFile () returnValue = False; result = dialog("What file to search?",2,""); if result.button = 1 filename = result.enteredtext; result = dialog("Host Connection for file, if not local?",2,""); if result.button = 1 connection = result.enteredtext; returnValue = True; endif endif return returnValue; endsub result = dialog("Regular Expression to Match?",2,""); if result.button = 2 stop; endif regexp = result.enteredtext; if (regexp = "") stop; endif; repeat while (typeof(file)<>qedit.typeobject) if not getFile() stop; endif; -- writelog(string(connection) + string(filename)); try file = open(connection: connection, filename: filename); recover result = dialog("Unable to open that file. Try again."); endtry endrepeat file.activate(); -- bring the file to the front file.select(line:1, column:1); -- may be at previous location after Open() if (file.find(regexp: regexp)) goFlag=true; else goFlag=false; result=dialog("No matches in this file"); endif repeat while (goFlag <> False) result=dialog("Search again?",2); if result.button=2 goFlag = false; else if not (file.find(regexp: regexp)) goFlag = false; result=dialog("End of file."); endif endif endrepeat; file.close(discardchanges:true); << Author: bgreen@robelle.com Date: Sept 30, 1999 Name: Regexp Group: Learning Notes: 1. Notice that variables can have the same name as parameter names (i.e., filename, connection and regexp). 2. After a successful Find(), the next search starts after the current match. In this way you do not keep matching the same string over and over. 3. This script uses a Try-Recover block to handle file open errors. >>