$ProcLoc
Locate any of set of strings in procedure
Note: Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for $ProcLoc is Locate, if AppendOpenProcedure is used to retrieve the procedure into a Stringlist.
The $ProcLoc function accepts five arguments and returns a numeric result.
The first four arguments identify strings to be located in the currently open procedure. If any of the specified strings is located in a given line of the procedure, the search is terminated. At least one search string must be specified. The total length of the first 4 arguments must be 256 or less.
The fifth argument, if set to 'Y', indicates that the case of the data in a procedure line must match the case of the data in the search strings for a string to be considered "matched." If this argument is not set to 'Y', a lowercase character would be considered to match the corresponding uppercase character, and vice versa.
The sixth argument, available in Sirius Mods 8.1 and later, if set to 'Y', indicates that single (') and double (") quotes are to be considered as matches for each other. This can be useful when searching through procedures that contain code where single and double quotes can be used interchangeably to enclose string literals. Such code includes User Language, Javascript, and XML (including XSLT).
Syntax
%rc = $ProcLoc( {string1, string2, string3, string4 }, [respect], [arb_quote])
Return codes
>0 - The number of lines that were tested before the string or strings were located -1 - Current include level not opened by $ProcOpn -2 - Search string or strings not found -3 - No search strings were specified -4 - Total length of search strings > 256
Usage notes
- $ProcLoc positions the "current line" in the file so that a subsequent $ProcGet would return the line containing the matched string or strings. If you wish to continue searching through the current procedure for the next occurrence of a string or strings you must issue a $ProcGet to advance the current line. If you do not, $ProcLoc will continue to match on the current line.
For example, the following code, displays the line number and contents of every line in procedure
BIGPROC
that contains either the stringREPEAT
or the stringARRAY
:%A = $ProcOpn('BIGPROC') %LINE_NUM = 0 %A = 1 REPEAT WHILE %A GT 0 %A = $ProcLoc('REPEAT','ARRAY') IF %A GT 0 THEN %LINE_NUM = %LINE_NUM + %A PRINT %LINE_NUM AND $ProcGet END IF END REPEAT