Compare (Stringlist function): Difference between revisions
m (1 revision) |
m (→Syntax terms) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 9: | Line 9: | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>% | <tr><th>%outList</th> | ||
<td>A <var>Stringlist</var> to contain the result of the comparison of the method and | <td>A <var>Stringlist</var> to contain the result of the comparison of the method input (<var class="term">sl</var>) and <var class="term">inList</var> <var>Stringlist</var>s.</td></tr> | ||
<tr><th>sl</th> | <tr><th>sl</th> | ||
<td>A <var>Stringlist</var> object.</td></tr> | <td>A <var>Stringlist</var> object. The first 8 characters of each item must be an 8-digit increasing integer; these are used as sequence numbers for the <var class="term">%outList</var> items. The comparison is made using the <var class="term">sl</var> items following the sequence numbers.</td></tr> | ||
<tr><th> | <tr><th>inList</th> | ||
<td>The input <var>Stringlist</var>, which contains data that does not include 8-byte sequence numbers. This is a required argument.</td></tr> | <td>The input <var>Stringlist</var>, which contains data that does not include 8-byte sequence numbers. This is a required argument.</td></tr> | ||
<tr><th> | <tr><th>syncCount</th> | ||
<td>A number indicating a synchronization count. When <var>sl<var>, the method <var>Stringlist</var>, and the <var> | <td>A number indicating a synchronization count. When <var class="term">sl</var>, the method <var>Stringlist</var>, and the <var class="term">inList</var> <var>Stringlist</var> are being compared and a difference is found, <var class="term">syncCount</var> indicates the number of lines that must match before they are treated as a true match. This is an optional argument, and it defaults to 1.</td></tr> | ||
<tr><th>pad</th> | <tr><th>pad</th> | ||
<td>The pad character to be used to pad any input | <td>The pad character to be used to pad any input item during the comparison to items in the other input <var>Stringlist</var>. This is an optional argument, and it defaults to blank.</td></tr> | ||
</table> | </table> | ||
Line 25: | Line 25: | ||
==Examples== | ==Examples== | ||
For example, assume the <var>Stringlist</var> object, identified by < | For example, assume the <var>Stringlist</var> object, identified by <code>%objList</code>, contains these items: | ||
<p class="code">00010000b | <p class="code">00010000b | ||
00020000 | 00020000 | ||
Line 33: | Line 32: | ||
00050000end | 00050000end | ||
</p> | </p> | ||
And the input argument <var>Stringlist</var>, identified by <code>%argList</code>, contains these items: | |||
And the input argument <var>Stringlist</var>, identified by < | |||
<p class="code">b | <p class="code">b | ||
Line 44: | Line 41: | ||
</p> | </p> | ||
This statement compares the <var> | This statement compares the two <var>Stringlists</var>: | ||
<p class="code">%outList = %objList:compare(%argList) | <p class="code">%outList = %objList:compare(%argList) | ||
</p> | </p> | ||
The result is the <var>Stringlist</var>, identified by < | The result is the <var>Stringlist</var>, identified by <code>%outList</code>, which contains: | ||
<p class="code">.li;./ I 00030000 $ 00030001 00010000 | <p class="code">.li;./ I 00030000 $ 00030001 00010000 | ||
print 'Harvard Diving Team, 1908' | print 'Harvard Diving Team, 1908' | ||
</p> | </p> | ||
The method <var>Stringlist</var> for <var>Compare</var> (<code>%objlist</code>, above) can be most easily created with <var>[[AppendOpenProcedure (Stringlist function)|AppendOpenProcedure]]</var>, using the third parameter, <var class="term">seqIncrement</var>, to indicate a sequence number. | |||
The method <var>Stringlist</var> for <var>Compare</var> (< | |||
==See also== | ==See also== | ||
{{Template:Stringlist:Compare footer}} | {{Template:Stringlist:Compare footer}} |
Latest revision as of 11:28, 9 November 2012
Compare two Stringlists and produce Stringlist describing differences (Stringlist class)
This method compares two Stringlists and produces a Stringlist describing the differences between the two.
The Compare method object, that is, the Stringlist against which Compare is being run, must have 8-byte long sequence numbers at the start of each item. As the term "sequence numbers" suggests, these numbers must consist exclusively of numeric characters with no leading blanks, and the numbers must be in ascending, sequential order. That is, the sequence number in each Stringlist item must be greater than the sequence number in the preceding item.
Syntax
[%outList =] sl:Compare( inList, [syncCount], [pad])
Syntax terms
%outList | A Stringlist to contain the result of the comparison of the method input (sl) and inList Stringlists. |
---|---|
sl | A Stringlist object. The first 8 characters of each item must be an 8-digit increasing integer; these are used as sequence numbers for the %outList items. The comparison is made using the sl items following the sequence numbers. |
inList | The input Stringlist, which contains data that does not include 8-byte sequence numbers. This is a required argument. |
syncCount | A number indicating a synchronization count. When sl, the method Stringlist, and the inList Stringlist are being compared and a difference is found, syncCount indicates the number of lines that must match before they are treated as a true match. This is an optional argument, and it defaults to 1. |
pad | The pad character to be used to pad any input item during the comparison to items in the other input Stringlist. This is an optional argument, and it defaults to blank. |
Usage notes
- All errors in Compare result in request cancellation.
- The output Stringlist produced by Compare is in a format that is suitable as input to Update.
Examples
For example, assume the Stringlist object, identified by %objList
, contains these items:
00010000b 00020000 00030000print 'Quentin Compson' 00040000 00050000end
And the input argument Stringlist, identified by %argList
, contains these items:
b print 'Quentin Compson' print 'Harvard Diving Team, 1908' end
This statement compares the two Stringlists:
%outList = %objList:compare(%argList)
The result is the Stringlist, identified by %outList
, which contains:
.li;./ I 00030000 $ 00030001 00010000 print 'Harvard Diving Team, 1908'
The method Stringlist for Compare (%objlist
, above) can be most easily created with AppendOpenProcedure, using the third parameter, seqIncrement, to indicate a sequence number.