Insert (Arraylist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 11: Line 11:
{{Template:Arraylist:Insert syntax}}
{{Template:Arraylist:Insert syntax}}
===Syntax terms===
===Syntax terms===
<dl>
<table class="syntaxTable">
<dt><i>%num</i>
<tr><th><i>%num</i></th>
<dd>A numeric variable to contain the number of
<td>A numeric variable to contain the number of items in the indicated Arraylist after the item has been inserted. </td></tr>
items in the indicated Arraylist after the item has been inserted.
<tr><th><i>%arrayl</i></th>
<dt><i>%arrayl</i>
<td>An Arraylist object. </td></tr>
<dd>An Arraylist object.
<tr><th><i>number</i></th>
<dt><i>number</i>
<td>A whole number greater than 0 to identify an ''%arrayl'' item. </td></tr>
<dd>A whole number greater than 0 to identify an ''%arrayl'' item.
<tr><th><i>item</i></th>
<dt><i>item</i>
<td>A value or variable of the same type as specified on the ''%arrayl'' declaration, or a value or variable convertible to that type.</td></tr>
<dd>A value or variable of the same
</table>
type as specified on the ''%arrayl'' declaration, or a value or variable
convertible to that type.
 
</dl>
==Usage notes==
==Usage notes==
<ul>
<ul>

Revision as of 23:28, 19 January 2011

Insert items into Arraylist (Arraylist class)

Insert is a member of the Arraylist class.

This callable function inserts an item before the number item in the Arraylist.

Syntax

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

Syntax terms

%num A numeric variable to contain the number of items in the indicated Arraylist after the item has been inserted.
%arrayl An Arraylist object.
number A whole number greater than 0 to identify an %arrayl item.
item A value or variable of the same type as specified on the %arrayl declaration, or a value or variable convertible to that type.

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.
  • For an example using the Insert method, see Arraylist class.