Update (Stringlist function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (syntax diagram, tags and links) |
||
Line 7: | Line 7: | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>% | <tr><th>%outList</th> | ||
<td>The output <var>Stringlist</var>.</td></tr> | <td>The output <var>Stringlist</var>.</td></tr> | ||
<tr><th>sl</th> | <tr><th>sl</th> | ||
<td>A <var>Stringlist</var> object that must contain items with 8-byte sequence numbers.</td></tr> | <td>A <var>Stringlist</var> object that must contain items with 8-byte sequence numbers.</td></tr> | ||
<tr><th> | <tr><th>updList</th> | ||
<td>A <var>Stringlist</var> that contains update control statements and insertion or replacement lines.</td></tr> | <td>A <var>Stringlist</var> that contains update control statements and insertion or replacement lines.</td></tr> | ||
<tr><th>status</th> | <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 | <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> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul><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 | <ul><li>All errors in <var>Update</var> other than an invalid update item cause request cancellation. | ||
<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 <var>Stringlist</var>.<dt>./ D seq1 { seq2 } { $ }<dd> This is a deletion control statement that indicates a range of input lines to be deleted. | <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>. The update control statements are: | |||
<dl><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 <var>Stringlist</var>. | |||
<dt>./ D <var class="term">seq1</var> { <var class="term">seq2</var> } { $ }<dd>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>. | |||
<dt>./ I <var class="term">seq1</var> { $ <var class="term">seq2</var> { <var class="term">seq3</var> } }<dd>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. | |||
<dt>./ R <var class="term">seq1</var> {<var class="term">seq3</var>} { $ <var class="term">seq3</var> { <var class="term">seq4</var> } }<dd> 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. | |||
<dt>./ S <var class="term">seq1</var> { <var class="term">seq2</var> } { $ }<dd>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>.</dl> | |||
</ul> | </ul> | ||
==See also== | ==See also== | ||
{{Template:Stringlist:Update footer}} | {{Template:Stringlist:Update footer}} |
Revision as of 01:04, 28 January 2011
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 {seq3} { $ 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.