Insert (Arraylist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (it's example dag nab it)
Line 7: Line 7:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%count</th>
<tr><th>%count</th>
<td>An, optional, numeric variable to return the number of items in the indicated <var>Arraylist</var> after the item has been inserted. </td></tr>
<td>An, optional, numeric variable to return the number of items in the indicated <var>Arraylist</var> after the items have been inserted. </td></tr>
<tr><th>al</th>
<tr><th>al</th>
<td>An <var>Arraylist</var> object. </td></tr>
<td>An <var>Arraylist</var> object. </td></tr>
<tr><th>number</th>
<tr><th>number</th>
<td>A whole number, from 1 to the number of items in <var class="term">al</var> plus one, to identify an <var class="term">al</var> item <b><i>before</i></b> which <var class="term">collectionItem</var> will be inserted.</td></tr>
<td>A whole number, from 1 to the number of items in <var class="term">al</var> plus one, to identify an <var class="term">al</var> item <b><i>before</i></b> which the items in <var class="term">itemList</var> will be inserted.</td></tr>
<tr><th>collectionItem</th>
<tr><th>itemList</th>
<td>A value or variable of the same type as specified on the <var class="term">al</var> declaration, or a value or variable convertible to that type; to be inserted into <var class="term">al</var>.</td></tr>
<td>Under <var class="product">Sirius Mods</var> 7.9 and later this can be a comma-delimited set of values or variables of the same type as specified on the <var class="term">al</var> declaration or collections of objects of the same type as specified on the <var class="term">al</var> declaration. Each of these, from left to right, is inserted into the method object <var>Arraylist</var>.
 
Under <var class="product">Sirius Mods</var> 7.8 and earlier <var>itemList</var> can only be a single value or variable of the same type as specified on the <var class="term">al</var> declaration, or a value or variable convertible to that type to be inserted into the method object <var>Arraylist</var>.
</td></tr>
</table>
</table>



Revision as of 02:43, 14 March 2011

Insert items into Arraylist (Arraylist class)

The Insert callable function inserts a new item before the number item in the Arraylist.

Syntax

[%count =] al:Insert( number, itemList)

Syntax terms

%count An, optional, numeric variable to return the number of items in the indicated Arraylist after the items have been inserted.
al An Arraylist object.
number A whole number, from 1 to the number of items in al plus one, to identify an al item before which the items in itemList will be inserted.
itemList Under Sirius Mods 7.9 and later this can be a comma-delimited set of values or variables of the same type as specified on the al declaration or collections of objects of the same type as specified on the al declaration. Each of these, from left to right, is inserted into the method object Arraylist.

Under Sirius Mods 7.8 and earlier itemList can only be a single value or variable of the same type as specified on the al declaration, or a value or variable convertible to that type to be inserted into the method object Arraylist.

Usage notes

  • If number is less than or equal to the number of items in the Arraylist, the new item is inserted before the indicated item.
  • If number is equal to the number of items in the Arraylist plus one, the new item is added to the end of the Arraylist.
  • If number is greater than the number of items in the Arraylist plus one, or less than or equal to zero, the request is cancelled.

Examples

  1. For an example using the Insert method, see "Arraylist class".

See also