$LIKE: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<p>The $LIKE function provides total control over the parsing and evaluation languages used in pattern matching. It has two language parameters: one to control the parsing language, LANGUSER, and one to control the evaluation language, LANGFILE.</p>
<p>
<p>The LANGLIKE operator and $LIKE function in expressions coordinate to provide consistency between the FIND statement and the IF statement, and avoid complicating the interpretation of the evaluation language parameter.</p>
The <var>$LIKE</var> function provides total control over the parsing and evaluation languages used in pattern matching. It has two language parameters: one to control the parsing language, <var>LANGUSER</var>, and one to control the evaluation language, <var>LANGFILE</var>.</p>
<b>Syntax</b>
<p>
<p class="code">$LIKE(<var class="term">string</var>,<var class="term">pattern</var>[,<var class="term">parse-lang</var>][,<var class="term">eval-lang</var>]])
The <var>LANGLIKE</var> operator and <var>$LIKE</var> function in expressions coordinate to provide consistency between the <var>FIND</var> statement and the <var>IF</var> statement, and avoid complicating the interpretation of the evaluation language parameter.</p>
 
==Syntax==
<p class="syntax">$LIKE(<span class="term">string</span>,<span class="term">pattern</span>[,<span class="term">parse-lang</span>][,<span class="term">eval-lang</span>]])
</p>
</p>
<b>Where</b>
 
<p><var>The string</var> argument represents the characters to verify. <var>It</var> must be one of the following:</p>
Where:
<ul>
<li>The <var class="term">string</var> argument represents the characters to verify. It must be one of the following:
<ul>
<ul>
<li>A literal enclosed in quotation marks.</li>
<li>A literal enclosed in quotation marks.</li>
</li>
 
<li>%variable.</li>
<li>%variable.</li>
</li>
 
<li>A field name without quotation marks. In this case, the function call must be embedded in a FOR EACH RECORD loop where the current value of the field is verified.</li>
<li>A field name without quotation marks. In this case, the function call must be embedded in a <var>FOR EACH RECORD</var> loop where the current value of the field is verified.</li>
</li>
</ul></li>
</ul>
 
<p><var>The required pattern argument is the string of characters to verify, which you can specify as a literal enclosed in quotation marks or as a %variable.</var></p>
<li>The required <var class="term">pattern</var> argument is the string of characters to verify, which you can specify as a literal enclosed in quotation marks or as a %variable.</li>
<p><var>The optional parse-lang</var> argument specifies the language to use for parsing. The parse-lang argument is handled as follows:</p>
 
<li>The optional <var class="term">parse-lang</var> argument specifies the language to use for parsing. The <var class="term">parse-lang</var> argument is handled as follows:
<ul>
<ul>
<li>Omitting this argument instructs <var class="product">Model&nbsp;204</var> to use U.S. English parsing rules, even if the value of the LANGUSER parameter is not US.</li>
<li>Omitting this argument instructs <var class="product">Model&nbsp;204</var> to use U.S. English parsing rules, even if the value of the <var>LANGUSER</var> parameter is not <code>US</code>.</li>
</li>
 
<li>An asterisk enclosed in quotation marks ('*') instructs <var class="product">Model&nbsp;204</var> to use the value of the LANGUSER parameter.</li>
<li>An asterisk enclosed in quotation marks (<tt>'*'</tt>) instructs <var class="product">Model&nbsp;204</var> to use the value of the <var>LANGUSER</var> parameter.</li>
</li>
 
<li>You can enter a literal name of a valid language enclosed in quotation marks. If you enter a name that is not supported, the request is canceled with an error message. See The LANGUSER parameter in the Rocket <var class="product">Model&nbsp;204</var> Parameter and Command Reference Manual for the valid values.</li>
<li>You can enter a literal name of a valid language enclosed in quotation marks. If you enter a name that is not supported, the request is canceled with an error message. See [[LANGUSER parameter]] for the valid values.</li>
</li>
</ul></li>
 
<li>The optional <var class="term">eval-lang</var> argument specifies the language to use for evaluation. Its requirements are identical to the <var class="term">parse-lang</var> argument.</li>
</ul>
</ul>
<p><var>The optional eval-lang</var> argument specifies the language to use for evaluation.</p>
 
<b>Example</b>
==Example==
<p>In the following example, we are matching the field NAME against the pattern (A-Z)*@ using US as the parsing language and TURKISH as the evaluation language. </p>
<p>
The following request matches the field <code>NAME</code> against the pattern <code>(A-Z)*@</code> using <code>US</code> as the parsing language and <code>TURKISH</code> as the evaluation language. </p>
<ul>
<ul>
<li>The parsing language, LANGUSER, determines the special characters that can be used in a pattern. The pattern is checked for syntax against these characters. The evaluation language, LANGFILE, is used when the pattern is matched against the data. </li>
<li>The parsing language, <var>LANGUSER</var>, determines the special characters that can be used in a pattern. The pattern is checked for syntax against these characters. The evaluation language, <var>LANGFILE</var>, is used when the pattern is matched against the data. </li>
</li>
 
<li>The evaluation language, LANGFILE, determines the collating sequence and the definition of alphabetic characters. </li>
<li>The evaluation language, <var>LANGFILE</var>, determines the collating sequence and the definition of alphabetic characters. </li>
</li>
</ul>
</ul>
<p>In this example, the evaluation language is Turkish. therefore all character matching is done against the Turkish alphabet and the range operation, (A-Z), uses the collating sequence of the Turkish language. </p>
<p>
In this example, the evaluation language is Turkish. Therefore all character matching is done against the Turkish alphabet, and the range operation, <code>(A-Z)</code>, uses the collating sequence of the Turkish language. </p>
<p class="code">BEGIN
<p class="code">BEGIN
FD1: IN DATA FIND ALL RECORDS
FD1: IN DATA FIND ALL RECORDS
Line 47: Line 56:
END
END
</p>
</p>
[[Category:SOUL $functions]]
[[Category:SOUL $functions]]

Latest revision as of 23:25, 8 March 2016

The $LIKE function provides total control over the parsing and evaluation languages used in pattern matching. It has two language parameters: one to control the parsing language, LANGUSER, and one to control the evaluation language, LANGFILE.

The LANGLIKE operator and $LIKE function in expressions coordinate to provide consistency between the FIND statement and the IF statement, and avoid complicating the interpretation of the evaluation language parameter.

Syntax

$LIKE(string,pattern[,parse-lang][,eval-lang]])

Where:

  • The string argument represents the characters to verify. It must be one of the following:
    • A literal enclosed in quotation marks.
    • %variable.
    • A field name without quotation marks. In this case, the function call must be embedded in a FOR EACH RECORD loop where the current value of the field is verified.
  • The required pattern argument is the string of characters to verify, which you can specify as a literal enclosed in quotation marks or as a %variable.
  • The optional parse-lang argument specifies the language to use for parsing. The parse-lang argument is handled as follows:
    • Omitting this argument instructs Model 204 to use U.S. English parsing rules, even if the value of the LANGUSER parameter is not US.
    • An asterisk enclosed in quotation marks ('*') instructs Model 204 to use the value of the LANGUSER parameter.
    • You can enter a literal name of a valid language enclosed in quotation marks. If you enter a name that is not supported, the request is canceled with an error message. See LANGUSER parameter for the valid values.
  • The optional eval-lang argument specifies the language to use for evaluation. Its requirements are identical to the parse-lang argument.

Example

The following request matches the field NAME against the pattern (A-Z)*@ using US as the parsing language and TURKISH as the evaluation language.

  • The parsing language, LANGUSER, determines the special characters that can be used in a pattern. The pattern is checked for syntax against these characters. The evaluation language, LANGFILE, is used when the pattern is matched against the data.
  • The evaluation language, LANGFILE, determines the collating sequence and the definition of alphabetic characters.

In this example, the evaluation language is Turkish. Therefore all character matching is done against the Turkish alphabet, and the range operation, (A-Z), uses the collating sequence of the Turkish language.

BEGIN FD1: IN DATA FIND ALL RECORDS END FIND %PAT='(A-Z)*@' FOR EACH RECORD IN FD1 %RC = $LIKE(NAME,%PAT,'US','TURKISH') IF %RC EQ 0 THEN PRINT 'STRING: 'WITH NAME WITH 'does not match PATTERN: - ' WITH %PAT END IF END FOR END