$ProcLoc: Difference between revisions
(Automatically generated page update) |
(Automatically generated page update) |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
<span class="pageSubtitle">Locate any of set of strings in procedure</span> | <span class="pageSubtitle">Locate any of set of strings in procedure</span> | ||
<p class=" | <p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for $ProcLoc is <var>[[Locate and LocateUp (Stringlist functions)|Locate]]</var>, if <var>[[AppendOpenProcedure (Stringlist function)|AppendOpenProcedure]]</var> is used to retrieve the procedure into a <var>Stringlist</var>.</p> | ||
The <var>$ProcLoc</var> function accepts five arguments and returns a numeric result. | The <var>$ProcLoc</var> 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 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" | 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 <var class="product">Sirius Mods</var> 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). | The sixth argument, available in <var class="product">Sirius Mods</var> 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== | ==Syntax== | ||
<p class="syntax"><span class="term">%rc</span> = <span class="literal">$ProcLoc</span>(<span class="term">string1</span>, <span class="term">string2</span>, <span class="term">string3</span>, <span class="term">string4</span>, <span class="term">respect</span>, <span class="term">arb_quote</span>) | <p class="syntax"><span class="term">%rc</span> = <span class="literal">$ProcLoc</span>( {<span class="term">string1</span>, <span class="term">string2</span>, <span class="term">string3</span>, <span class="term">string4</span> }, [<span class="term">respect</span>], [<span class="term">arb_quote</span>]) | ||
</p> | </p> | ||
<var>$ProcLoc</var> positions the "current line" in the file so that a subsequent <var>[[$ProcGet]]</var> 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 <var>$ProcGet</var> to advance the current line. If you do not, <var>$ProcLoc</var> will continue to match on the current line. For example, the following code, displays the line number and contents of every line in procedure <code>BIGPROC</code> that contains either the string <code>REPEAT</code> or the string <code>ARRAY</code> | ===Return codes=== | ||
<p class="code">>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 | |||
</p> | |||
==Usage notes== | |||
<ul> | |||
<li><var>$ProcLoc</var> positions the "current line" in the file so that a subsequent <var>[[$ProcGet]]</var> 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 <var>$ProcGet</var> to advance the current line. If you do not, <var>$ProcLoc</var> will continue to match on the current line. | |||
<p> | |||
For example, the following code, displays the line number and contents of every line in procedure <code>BIGPROC</code> that contains either the string <code>REPEAT</code> or the string <code>ARRAY</code>: </p> | |||
<p class="code">%A = $ProcOpn('BIGPROC') | <p class="code">%A = $ProcOpn('BIGPROC') | ||
Line 28: | Line 42: | ||
END REPEAT | END REPEAT | ||
</p> | </p> | ||
</ul> | |||
</ | |||
==Products authorizing {{PAGENAMEE}}== | ==Products authorizing {{PAGENAMEE}}== | ||
<ul class="smallAndTightList"> | <ul class="smallAndTightList"> | ||
<li>[[Sirius | <li>[[Sirius Functions]] | ||
<li>[[Fast/Unload User Language Interface]] | <li>[[Fast/Unload User Language Interface]] | ||
<li>[[Janus Web Server]] | <li>[[Janus Web Server]] | ||
</ul> | </ul> | ||
[[Category:$Functions|$ProcLoc]] | [[Category:$Functions|$ProcLoc]] |
Latest revision as of 22:52, 20 September 2018
Locate any of set of strings in procedure
Note: Many $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