Insert (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (almost re-match syntax diagram to revised template; fix tags.)
mNo edit summary
Line 11: Line 11:
<tr><th>string</th>
<tr><th>string</th>
<td>The input string</td></tr>
<td>The input string</td></tr>
<tr><th>insrtString</th>
<tr><th>insertedString</th>
<td>The new <var class="term">string</var> to be inserted into method object <var class="term">string</var>.</td></tr>
<td>The new text string to be inserted into method object <var class="term">string</var>.</td></tr>
<tr><th>position</th>
<tr><th>position</th>
<td>The numeric value of the position in the method object <var class="term">string</var> <b><i>before</i></b> which to insert <var class="term">insrtString</var>.  The first character from the left in the method object is position 1.  The value of <var class="term">position</var> must be between 1 and the number of characters in the method object <var class="term">string</var> plus one. An invalid position produces a request cancellation.</td></tr>
<td>The numeric value of the position in the method object <var class="term">string</var> <b><i>before</i></b> which to insert <var class="term">insertedString</var>.  The first character from the left in the method object is position 1.  The value of <var class="term">position</var> must be between 1 and the number of characters in the method object <var class="term">string</var> plus one. An invalid position produces a request cancellation.</td></tr>
</table>
</table>


==Usage Notes==
==Usage Notes==
<ul><li><var>Insert</var> is available as of <var class="product">Sirius Mods</var> version 7.6.</ul>
<ul><li><var>Insert</var> is available as of <var class="product">[[Sirius Mods]]</var> Version 7.6.</ul>


==Examples==
==Examples==
Line 27: Line 27:
   printText {~} = {'ABC':insert('xyz', 4)}
   printText {~} = {'ABC':insert('xyz', 4)}
   printText {~} = {'ABC':insert('xyz', 5)}
   printText {~} = {'ABC':insert('xyz', 5)}
End
end
</p>
</p>
The request result is:
The request result is:

Revision as of 23:29, 2 February 2011

Insert argument string inside the method object string (String class)


Insert is an intrinsic function that inserts an argument string inside the method object string, starting before the specified position in the method object string.

Syntax

%outString = string:Insert( insertedString, position)

Syntax terms

%outString A string variable to receive the modified method object string.
string The input string
insertedString The new text string to be inserted into method object string.
position The numeric value of the position in the method object string before which to insert insertedString. The first character from the left in the method object is position 1. The value of position must be between 1 and the number of characters in the method object string plus one. An invalid position produces a request cancellation.

Usage Notes

Examples

  1. The following request contains four Insert method calls:

    begin printText {~} = {:insert('xyz', 1)} printText {~} = {'ABC':insert('xyz', 3)} printText {~} = {'ABC':insert('xyz', 4)} printText {~} = {'ABC':insert('xyz', 5)} end

    The request result is:

    :insert('xyz', 1) = xyz 'abc':insert('xyz', 3) = ABxyzC 'abc':insert('xyz', 4) = ABCxyz 'abc':insert('xyz', 5) = *** 1 CANCELLING REQUEST: MSIR.0750: Class STRING, function INSERT: insertion position greater than length of input string plus one in line 5

See also