Insert (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 2: Line 2:


This [[Intrinsic classes|intrinsic]] function inserts an argument string inside the method object string,
This [[Intrinsic classes|intrinsic]] function inserts an argument string inside the method object string,
starting before the specified position in the method object string.                                    
starting before the specified position in the method object string.
                                                                                                       
 
Insert is available as of version 7.6 of the [[Sirius Mods]].                                          
Insert is available as of version 7.6 of the [[Sirius Mods]].
==Syntax==
==Syntax==
{{Template:String:Insert syntax}}
{{Template:String:Insert syntax}}
Line 18: Line 18:
<td>The numeric value of the position in the method object string before which                          to insert ''%insrtString''.                                                                              The first character from the left in the method object is position ''''1''''.                                                                                                                                    The value of ''%before'' must be between 1 and the number                                                of characters in the method object string plus one.                                                      An invalid position produces a request cancellation.</td></tr>
<td>The numeric value of the position in the method object string before which                          to insert ''%insrtString''.                                                                              The first character from the left in the method object is position ''''1''''.                                                                                                                                    The value of ''%before'' must be between 1 and the number                                                of characters in the method object string plus one.                                                      An invalid position produces a request cancellation.</td></tr>
</table>
</table>
                                                                                                   
 
==Examples==
==Examples==
                                                                                                       
 
The following request contains four Insert method calls:                                                
The following request contains four Insert method calls:
     Begin                                                                                              
     Begin
     [[Intrinsic classes#printtext|printText]] {~} = {'':insert('xyz', 1)}                                      
     [[Intrinsic classes#printtext|printText]] {~} = {'':insert('xyz', 1)}
     printText {~} = {'ABC':insert('xyz', 3)}
     printText {~} = {'ABC':insert('xyz', 3)}
     printText {~} = {'ABC':insert('xyz', 4)}                    
     printText {~} = {'ABC':insert('xyz', 4)}
     printText {~} = {'ABC':insert('xyz', 5)}                    
     printText {~} = {'ABC':insert('xyz', 5)}
     End                                                        
     End
                                                               
 
The request result is:                                          
The request result is:
     '':insert('xyz', 1) = xyz                                  
     '':insert('xyz', 1) = xyz
     'abc':insert('xyz', 3) = ABxyzC                            
     'abc':insert('xyz', 3) = ABxyzC
     'abc':insert('xyz', 4) = ABCxyz                            
     'abc':insert('xyz', 4) = ABCxyz
     'abc':insert('xyz', 5) =                                    
     'abc':insert('xyz', 5) =
       ***  1  CANCELLING REQUEST: MSIR.0750: Class STRING,      
       ***  1  CANCELLING REQUEST: MSIR.0750: Class STRING,
       function INSERT: insertion position greater than length  
       function INSERT: insertion position greater than length
       of input string plus one in line 5
       of input string plus one in line 5


===See also===                                                                                        
===See also===
[[List of intrinsic String methods]]
[[List of intrinsic String methods]]


[[Category:Intrinsic String methods|Insert function]]
[[Category:Intrinsic String methods|Insert function]]
[[Category:Intrinsic methods]]
[[Category:Intrinsic methods]]

Revision as of 14:04, 19 January 2011

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


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

Insert is available as of version 7.6 of the Sirius Mods.

Syntax

%outString = string:Insert( insertedString, position)

Syntax terms

%outStr A string variable to receive the modified method object string.
string The input string or Longstring.
%insrtString The byte number in the method object that is the starting point of the substring that is returned.
%before The numeric value of the position in the method object string before which to insert %insrtString. The first character from the left in the method object is position '1'. The value of %before must be between 1 and the number of characters in the method object string plus one. An invalid position produces a request cancellation.

Examples

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

List of intrinsic String methods