Update (Stringlist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
m (Change seq3 to seq2 for ./ R)
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:Stringlist:Update subtitle}}
{{Template:Stringlist:Update subtitle}}


This method uses an input Stringlist to update the method Stringlist, producing an output Stringlist that contains data from the method Stringlist as modified by the first argument Stringlist. The Update method accepts two arguments and returns a Stringlist. The method Stringlist must contain items with 8-byte sequence numbers.
This method uses an input <var>Stringlist</var> to update the method <var>Stringlist</var>, producing an output <var>Stringlist</var> that contains data from the method <var>Stringlist</var> as modified by the first argument <var>Stringlist</var>. The <var>Update</var> method accepts two arguments and returns a <var>Stringlist</var>. The method <var>Stringlist</var> must contain items with 8-byte sequence numbers.
 
Update is a member of the [[Stringlist class]].


==Syntax==
==Syntax==
{{Template:Stringlist:Update syntax}}
{{Template:Stringlist:Update syntax}}
===Syntax terms===
===Syntax terms===
<dl>
<table class="syntaxTable">
<dt>%outlist<dd>The output Stringlist.<dt>%sl<dd>A Stringlist object that must contain items with 8-byte sequence numbers.<dt>updlist<dd>A Stringlist that contains update control statements and insertion or replacement lines.<dt>%status<dd>A numeric variable that is set to 0 if the method is successful, or it is set to the item number of the invalid update command if '''updlist''' contains an invalid item. This is an optional output argument.  
<tr><th>%outList</th>
</dl>
<td>The output <var>Stringlist</var>.</td></tr>
<tr><th>sl</th>
<td>A <var>Stringlist</var> object that must contain items with 8-byte sequence numbers.</td></tr>
<tr><th>updList</th>
<td>A <var>Stringlist</var> that contains update control statements and insertion or replacement lines.</td></tr>
<tr><th>%status</th>
<td>A numeric variable that is set to 0 if the method is successful, or it is set to the item number of the invalid update command if <var class="term">updList</var> contains an invalid item. This is an optional output argument.</td></tr>
</table>


==Usage notes==
==Usage notes==
<ul><li>All errors in Update other than an invalid update item cause request cancellation.<li>The output Stringlist produced by Update contains sequence numbers just as the input Stringlist in the first argument. This makes it possible to use the output Stringlist as input to another Update call. In this way it is possible to apply multiple updates to a single Stringlist.<li>The method Stringlist for Update can be most easily created with the AppendOpenProcedure method (:hdref reftxt=AppendOpenProcedure refid=appopen.) using its fourth parameter to indicate a sequence number. The input argument Stringlist to Update can be most easily created with the Compare method (:hdref reftxt=Compare refid=slcomp.).<li>The update Stringlist contains update control statements and insertion or replacement lines. The update Stringlist must begin with an update control statement. All update control statements begin with the period-slash character sequence (./); this is followed by a single character indicating the function, and then possibly by sequence numbers indicating the lines in the input Stringlist to which the updates apply. Any items in the method Stringlist that are not updated by the update Stringlist are simply copied into the output Stringlist. The update control statements are:<dl>
<ul>
<dt>./ * comment<dd> This is a comment control statement and it is ignored. It must be followed by another update control statement, or it must be the last item in the update Stringlist.<dt>./ D seq1 { seq2 } { $ }<dd> This is a deletion control statement that indicates a range of input lines to be deleted. '''seq1''' and '''seq2''' indicate the range of sequence numbers in the method Stringlist that are to be deleted. If '''seq2''' is not specified, it is assumed to equal '''seq1''', so only the single line indicated by '''seq1''' will be deleted. This statement must be followed by another update control statement, or it must be the last item in the update Stringlist.<dt>./ I seq1 { $ seq2 { seq3 } }<dd> This is an insertion control statement, and it is followed by lines that are to be inserted in the output Stringlist. '''seq1''' indicates the sequence number in the method Stringlist after which the lines are to be inserted. '''seq2''' is the sequence number to be assigned to the first inserted line, and '''seq3''' indicates the increment to be added to the current sequence number for subsequent inserted lines. The lines to be inserted are terminated by another update control statement.<dt>./ R seq1 {seq2} { $ seq3 { seq4 } }<dd> This is a replacement control statement, and it is followed by lines that are to replace lines from the method Stringlist in the output Stringlist. '''seq1''' and '''seq2''' indicate the range of sequence numbers in the input Stringlist that are to be replaced. If '''seq2''' is not specified, it is assumed to equal '''seq1''', so only the single line indicated by '''seq1''' will be replaced. '''seq3''' is the sequence number to be assigned to the first replacement line, and '''seq4''' indicates the increment to be added to the current sequence number for subsequent replacement lines. The replacement lines are terminated by another update control statement.<dt>./ S seq1 { seq2 } { $ }<dd> This is a resequence control statement, and it must be the first non-comment control statement in the update Stringlist. This statement indicates that the output Stringlist, after all subsequent updates have been applied, is to be given sequence numbers starting at '''seq1''' and incremented by '''seq2'''.</dl>
<li>All errors in <var>Update</var> other than an invalid update item cause request cancellation.
<li>The output <var>Stringlist</var> produced by <var>Update</var> contains sequence numbers just as the input <var>Stringlist</var> in the first argument. This makes it possible to use the output <var>Stringlist</var> as input to subsequent <var>Update</var> call. In this way it is possible to apply multiple updates to a single <var>Stringlist</var>.
<li>The method <var>Stringlist</var> for <var>Update</var> can be most easily created with <var>[[AppendOpenProcedure (Stringlist function)|AppendOpenProcedure]]</var> using its fourth parameter to indicate a sequence number. The input argument <var>Stringlist</var> to <var>Update</var> can be most easily created with <var>[[Compare (Stringlist function)|Compare]]</var>.
<li>The update <var>Stringlist</var> contains update control statements and insertion or replacement lines. The update <var>Stringlist</var> must begin with an update control statement. All update control statements begin with the period-slash character sequence (<code>./</code>); this is followed by a single character indicating the function, and then possibly by sequence numbers indicating the lines in the input <var>Stringlist</var> to which the updates apply. Any items in the method <var>Stringlist</var> that are not updated by the update <var>Stringlist</var> are simply copied into the output <var>Stringlist</var>.  
<p>
The update control statements are:</p>
<table>
<tr><th>./ * comment</th>
<td>This is a comment control statement and it is ignored. It must be followed by another update control statement, or it must be the last item in the update <var>Stringlist</var>.</td></tr>
 
<tr><th>./ D <var class="term">seq1</var> { <var class="term">seq2</var> } { $ }</th>
<td>This is a deletion control statement that indicates a range of input lines to be deleted. <var class="term">seq1</var> and <var class="term">seq2</var> indicate the range of sequence numbers in the method <var>Stringlist</var> that are to be deleted. If <var class="term">seq2</var> is not specified, it is assumed to equal <var class="term">seq1</var>, so only the single line indicated by <var class="term">seq1</var> will be deleted. This statement must be followed by another update control statement, or it must be the last item in the update <var>Stringlist</var>.</td></tr>
 
<tr><th>./ I <var class="term">seq1</var> { $ <var class="term">seq2</var> { <var class="term">seq3</var> } }</th>
<td>This is an insertion control statement, and it is followed by lines that are to be inserted in the output <var>Stringlist</var>. <var class="term">seq1</var> indicates the sequence number in the method <var>Stringlist</var> after which the lines are to be inserted. <var class="term">seq2</var> is the sequence number to be assigned to the first inserted line, and <var class="term">seq3</var> indicates the increment to be added to the current sequence number for subsequent inserted lines. The lines to be inserted are terminated by another update control statement.</td></tr>
 
<tr><th nowrap>./ R <var class="term">seq1</var> {<var class="term">seq2</var>} { $ <var class="term">seq3</var> { <var class="term">seq4</var> } }</th>
<td>This is a replacement control statement, and it is followed by lines that are to replace lines from the method <var>Stringlist</var> in the output <var>Stringlist</var>. <var class="term">seq1</var> and <var class="term">seq2</var> indicate the range of sequence numbers in the input <var>Stringlist</var> that are to be replaced. If <var class="term">seq2</var> is not specified, it is assumed to equal <var class="term">seq1</var>, so only the single line indicated by <var class="term">seq1</var> will be replaced. <var class="term">seq3</var> is the sequence number to be assigned to the first replacement line, and <var class="term">seq4</var> indicates the increment to be added to the current sequence number for subsequent replacement lines. The replacement lines are terminated by another update control statement.</td></tr>
 
<tr><th>./ S <var class="term">seq1</var> { <var class="term">seq2</var> } { $ }</th>
<td>This is a resequence control statement, and it must be the first non-comment control statement in the update <var>Stringlist</var>. This statement indicates that the output <var>Stringlist</var>, after all subsequent updates have been applied, is to be given sequence numbers starting at <var class="term">seq1</var> and incremented by <var class="term">seq2</var>.</td></tr>
</table>
</ul>
</ul>


[[Category:Stringlist methods|Update function]]
==See also==
{{Template:Stringlist:Update footer}}

Latest revision as of 06:30, 8 January 2014

Produce Stringlist from input Stringlist using Stringlist of updates (Stringlist class)


This method uses an input Stringlist to update the method Stringlist, producing an output Stringlist that contains data from the method Stringlist as modified by the first argument Stringlist. The Update method accepts two arguments and returns a Stringlist. The method Stringlist must contain items with 8-byte sequence numbers.

Syntax

%outList = sl:Update( updList, [%status])

Syntax terms

%outList The output Stringlist.
sl A Stringlist object that must contain items with 8-byte sequence numbers.
updList A Stringlist that contains update control statements and insertion or replacement lines.
%status A numeric variable that is set to 0 if the method is successful, or it is set to the item number of the invalid update command if updList contains an invalid item. This is an optional output argument.

Usage notes

  • All errors in Update other than an invalid update item cause request cancellation.
  • The output Stringlist produced by Update contains sequence numbers just as the input Stringlist in the first argument. This makes it possible to use the output Stringlist as input to subsequent Update call. In this way it is possible to apply multiple updates to a single Stringlist.
  • The method Stringlist for Update can be most easily created with AppendOpenProcedure using its fourth parameter to indicate a sequence number. The input argument Stringlist to Update can be most easily created with Compare.
  • The update Stringlist contains update control statements and insertion or replacement lines. The update Stringlist must begin with an update control statement. All update control statements begin with the period-slash character sequence (./); this is followed by a single character indicating the function, and then possibly by sequence numbers indicating the lines in the input Stringlist to which the updates apply. Any items in the method Stringlist that are not updated by the update Stringlist are simply copied into the output Stringlist.

    The update control statements are:

    ./ * comment This is a comment control statement and it is ignored. It must be followed by another update control statement, or it must be the last item in the update Stringlist.
    ./ D seq1 { seq2 } { $ } This is a deletion control statement that indicates a range of input lines to be deleted. seq1 and seq2 indicate the range of sequence numbers in the method Stringlist that are to be deleted. If seq2 is not specified, it is assumed to equal seq1, so only the single line indicated by seq1 will be deleted. This statement must be followed by another update control statement, or it must be the last item in the update Stringlist.
    ./ I seq1 { $ seq2 { seq3 } } This is an insertion control statement, and it is followed by lines that are to be inserted in the output Stringlist. seq1 indicates the sequence number in the method Stringlist after which the lines are to be inserted. seq2 is the sequence number to be assigned to the first inserted line, and seq3 indicates the increment to be added to the current sequence number for subsequent inserted lines. The lines to be inserted are terminated by another update control statement.
    ./ R seq1 {seq2} { $ seq3 { seq4 } } This is a replacement control statement, and it is followed by lines that are to replace lines from the method Stringlist in the output Stringlist. seq1 and seq2 indicate the range of sequence numbers in the input Stringlist that are to be replaced. If seq2 is not specified, it is assumed to equal seq1, so only the single line indicated by seq1 will be replaced. seq3 is the sequence number to be assigned to the first replacement line, and seq4 indicates the increment to be added to the current sequence number for subsequent replacement lines. The replacement lines are terminated by another update control statement.
    ./ S seq1 { seq2 } { $ } This is a resequence control statement, and it must be the first non-comment control statement in the update Stringlist. This statement indicates that the output Stringlist, after all subsequent updates have been applied, is to be given sequence numbers starting at seq1 and incremented by seq2.

See also