Compare (Stringlist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 1: Line 1:
{{Template:Stringlist:Compare subtitle}}
{{Template:Stringlist:Compare subtitle}}


This method compares two Stringlists and produces a Stringlist describing the differences between the two.  
This method compares two <var>Stringlist</var>s and produces a <var>Stringlist</var> 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 sequential order. That is, the sequence number in each Stringlist item must be greater than the sequence number in the preceding item.
The Compare method object, that is, the <var>Stringlist</var> 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 sequential order. That is, the sequence number in each <var>Stringlist</var> item must be greater than the sequence number in the preceding item.


==Syntax==
==Syntax==
Line 10: Line 10:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%outlist</th>
<tr><th>%outlist</th>
<td>A Stringlist to contain the result of the comparison of the method and input Stringlists.</td></tr>
<td>A <var>Stringlist</var> to contain the result of the comparison of the method and input <var>Stringlist</var>s.</td></tr>
<tr><th>sl</th>
<tr><th>sl</th>
<td>A Stringlist object.</td></tr>
<td>A <var>Stringlist</var> object.</td></tr>
<tr><th>inlist</th>
<tr><th>inlist</th>
<td>The input Stringlist, 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>synccount</th>
<tr><th>synccount</th>
<td>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.</td></tr>
<td>A number indicating a synchronization count. When '''%sl''', the method <var>Stringlist</var>, and the '''inlist''' <var>Stringlist</var> 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.</td></tr>
<tr><th>pad</th>
<tr><th>pad</th>
<td>The pad character to be used to pad any input line that is too short. This is an optional argument, and it defaults to blank.</td></tr>
<td>The pad character to be used to pad any input line that is too short. This is an optional argument, and it defaults to blank.</td></tr>
Line 25: Line 25:


==Examples==
==Examples==
The output Stringlist produced by Compare is in a format that is suitable as input to the [[Update (Stringlist function)]]. For example, the method Stringlist contains these items:
The output <var>Stringlist</var> produced by Compare is in a format that is suitable as input to the [[Update (Stringlist function)]]. For example, the method <var>Stringlist</var> contains these items:


<pre>
<pre>
Line 35: Line 35:
</pre>
</pre>


And the input argument Stringlist contains these items:
And the input argument <var>Stringlist</var> contains these items:


<pre>
<pre>
Line 46: Line 46:
</pre>
</pre>


This statement compares the Stringlists:
This statement compares the <var>Stringlist</var>s:


<pre>
<pre>
Line 52: Line 52:
</pre>
</pre>


The result is the Stringlist identified by %outList, which contains:
The result is the <var>Stringlist</var> identified by %outList, which contains:


<pre>
<pre>
Line 59: Line 59:
</pre>
</pre>


The method Stringlist for Compare (<tt>.%objlist</tt>, above) can be most easily created with the [[AppendOpenProcedure (Stringlist function)]]), using the third parameter to indicate a sequence number.
The method <var>Stringlist</var> for Compare (<tt>.%objlist</tt>, above) can be most easily created with the [[AppendOpenProcedure (Stringlist function)]]), using the third parameter to indicate a sequence number.


[[Category:Stringlist methods|Compare function]]
[[Category:Stringlist methods|Compare function]]

Revision as of 21:33, 18 January 2011

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 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 and input Stringlists.
sl A Stringlist object.
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 line that is too short. This is an optional argument, and it defaults to blank.

Usage notes

  • All errors in Compare result in request cancellation.

Examples

The output Stringlist produced by Compare is in a format that is suitable as input to the Update (Stringlist function). For example, the method Stringlist contains these items:

00010000b
00020000
00030000print 'Quentin Compson'
00040000
00050000end

And the input argument Stringlist contains these items:

b

print 'Quentin Compson'
print 'Harvard Diving Team, 1908'

end

This statement compares the 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 the AppendOpenProcedure (Stringlist function)), using the third parameter to indicate a sequence number.