>>******************************************************************** >>* Description.......: SearchScx - searches all SCX files for sSearchString in MethodToSearch >>* Calling Samples...: >>* Parameter List....: pcSearchString, pcMethodToSearch >>* Created by........: Ed Rauh >>* Modified by.......: Nadya Nosonovsky 10/18/2000 03:01:23 PM >>******************************************************************** >>lparameters pcSearchString, pcMethodToSearch >>if vartype(pcSearchString)'C' >> pcSearchString=upper("SetFocus") >>else >> pcSearchString=upper(pcSearchString) >>endif >>if vartype(pcMethodToSearch)'C' >> pcMethodToSearch=upper("Init") >>else >> pcMethodToSearch=upper(pcMethodToSearch) >>endif >>=GetAllFiles1('\redp\appl','scx') && Creates cursor filesADIR of all scx files >>local oReg, lcTextString >>oReg = createobject('VBScript.RegExp') >>oReg.global = .t. * * The .Global property tells the RegExp object to search for more than one * occurance of the pattern in the string * >>oReg.IgnoreCase = .t. * * .IgnoreCase performs compares in a case - insensitive manner * >>oReg.pattern = 'PROCEDURE '+pcMethodToSearch+'([^\0]*)ENDPROC' * * .Pattern is the heart of the object - it describes the regular expression to * search for. Our pattern is the word "PROCEDURE" followed by a space, * followed by the content of the variable pcMethodToSearch. In a real life * situation, we'd want to parse pcMethodToSearch a character at a time, so * that if any of the special characters "\^$*+?.(){}|-," occurred, we'd force * them to be literals, so the string 'Mr. Smith-Jones' would be changed into * 'Mr\. Smith\-Jones'. Alternatively, we might work on the premise that the * user knows about regular expressions; he could intentionally enter a * regular expression instead of a simple literal, eg '\w*_ACCESS' would get * all the _ACCESS methods. The same core code for either behavior will * fit different users - it looks like a candidate for a class hierarchy * * The balance of the expression is any number of non-null characters, followed * by the string 'ENDPROC' * >>#define CRLF chr(13)+chr(10) >>lcTextString = '' >>select FilesAdir && cursor with all scx files >>scan >> if file(forceext(cFileName,'sct')) && Memo file is where >> use (cFileName) alias ThisSCX in 0 noupdate >> select ThisSCX >> scan for 'form ' $ lower(baseclass + ' ') and ! empty(Methods) >> Matches=oReg.Execute(ThisSCX.Methods) * * This extracts all occurances of the regular expression contained within * the () scoping into a colection. The collection has a Value, the match * string itself, StartPosition, the 1-indexed position of the match, and * Length, the length of the match * >> for each oMatch in Matches >> if pcSearchString $ upper(oMatch.value) >> lcTextString = lcTextString + FilesAdir.cFileName+ ': ' +ThisSCX.ObjName + CRLF + ; >> oMatch.value + CRLF + CRLF * * We've recorded the name of the file, the name of the object in the file, * and the actual content of the method. Setting flag doesn't do anything * that appears useful * >> replace flag with .t. in FilesAdir >> endif >> endfor && each match >> endscan && each form rec in SCX >> use in ThisSCX >> endif >> select FilesAdir && safety meassure >>endscan && each app dir >>if len(lcTextString) > 0 >> =strtofile(lcTextString,'Result.TXT') >> modi file 'Result.TXT' >>endif