Item (NamedArraylist property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (match syntax table to diagram, lots of tags, some edits)
Line 1: Line 1:
{{Template:NamedArraylist:Item subtitle}}
{{Template:NamedArraylist:Item subtitle}}


This ReadWrite property returns or sets the value of the item that has the
<var>Item</var> is a ReadWrite property returns or sets the value of the item that has the given name in the <var>NamedArraylist</var>.
given name in the NamedArraylist.
 
For additional comments about the <var>Item</var> method in collections, see [[Collections#Coding considerations for collections|"Coding considerations for collections"]].


For additional comments about the Item method in collections,
see [[Collections#Coding considerations for collections|Coding considerations for collections]].
==Syntax==
==Syntax==
{{Template:NamedArraylist:Item syntax}}
{{Template:NamedArraylist:Item syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%item</th>
<tr><th>%currentItem</th>
<td>A variable of the same type as specified on the ''%namrayl'' declaration to contain the value of the specified ''%namrayl'' item. Or a variable or value of the same type as specified on the ''%namrayl'' declaration to be assigned to the specified ''%namrayl'' item. </td></tr>
<td>A variable of the same type as specified on the <var class="term">nal</var> declaration to contain the value of the specified <var class="term">nal</var> item.</td></tr>
<tr><th>%namrayl</th>
<tr><th>nal</th>
<td>A NamedArraylist object. </td></tr>
<td>A <var>NamedArraylist</var> object.</td></tr>
<tr><th>name</th>
<tr><th>string</th>
<td>A string that serves as a subscript to identify a ''%namrayl'' item.</td></tr>
<td>A string that serves as a subscript to identify a <var class="term">nal</var> item.</td></tr>
<tr><th>newItem</th>
<td>A variable or value of the same type as specified on the <var class="term">nal</var> declaration to be assigned to the specified <var class="term">nal</var> item. </td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>If the Item property is being set and there is already an item
<li>If the <var>Item</var> property is being set and there is already an item on the <var>NamedArraylist</var> that has the specified name, that item is replaced. If the <var>Item</var> property is being set and there is no item on the <var>NamedArraylist</var> that has the indicated name, the item is added. If the <var>Item</var> property is being retrieved and there is no item on the <var>NamedArraylist</var> that has the indicated name, the result is one of the following actions:
on the NamedArraylist that has the specified name, that item is replaced.
 
If the Item property is being set and there is no item on the NamedArraylist
that has the indicated name, the item is added.
 
If the Item property is being retrieved and there is no item on the NamedArraylist
that has the indicated name, the result is one of the following actions:
<ul>
<ul>
<li>The request is cancelled if the [[UseDefault (NamedArraylist property)|UseDefault]]
<li>The request is cancelled if the <var>[[UseDefault (NamedArraylist property)|UseDefault]]</var> property value is <code>False</code>.
property value is <tt>False</tt>.
<li>The <var>[[Default (NamedArraylist property)|Default]]</var> value is returned if the <var>UseDefault</var> property is <code>True</code>.
<li>The [[Default (NamedArraylist property)|Default]] value is returned if the
UseDefault property is <tt>True</tt>.
</ul>
</ul>
<li>The <tt>Item</tt> keyword is not required.
<li>The <code>Item</code> keyword is not required. For example, in the request at the start of the <var>[[NamedArraylist class]]</var>, <code>%alist('Idle') = 'Eric'</code>, for instance, is equivalent to:
For example, in the request at the start of the
[[NamedArraylist class]], <tt>%alist('Idle') = 'Eric'</tt>, for instance,
is equivalent to:
<p class="code">%alist:Item('Idle') = 'Eric'
<p class="code">%alist:Item('Idle') = 'Eric'
</p>
</p>
<li>As shown in the example at the start of the [[NamedArraylist class]],
<li>As shown in the example at the start of the [[NamedArraylist class]], <var>NamedArraylist</var> items are ordered alphabetically by their names. Accordingly, the <var>Item</var> method takes a name argument <var class="term">string</var>.
NamedArraylist items are ordered alphabetically by their names.
Accordingly, the Item method takes a ''name'' argument.
The ItemByNumber method, described below,
lets you retrieve or set an item using its item number.
</ul>
</ul>
==See also==
==See also==
<ul><li>The <var>[[ItemByNumber_(GenericNamedArraylist_property)|ItemByNumber]]</var> method, lets you retrieve or set an item using its item number.
</ul>
{{Template:NamedArraylist:Item footer}}
{{Template:NamedArraylist:Item footer}}

Revision as of 09:07, 4 March 2011

Value of named item (NamedArraylist class)


Item is a ReadWrite property returns or sets the value of the item that has the given name in the NamedArraylist.

For additional comments about the Item method in collections, see "Coding considerations for collections".

Syntax

%currentItem = nal:Item( string) nal:Item( string) = newItem Throws ItemNotPresent

Syntax terms

%currentItem A variable of the same type as specified on the nal declaration to contain the value of the specified nal item.
nal A NamedArraylist object.
string A string that serves as a subscript to identify a nal item.
newItem A variable or value of the same type as specified on the nal declaration to be assigned to the specified nal item.

Usage notes

  • If the Item property is being set and there is already an item on the NamedArraylist that has the specified name, that item is replaced. If the Item property is being set and there is no item on the NamedArraylist that has the indicated name, the item is added. If the Item property is being retrieved and there is no item on the NamedArraylist that has the indicated name, the result is one of the following actions:
    • The request is cancelled if the UseDefault property value is False.
    • The Default value is returned if the UseDefault property is True.
  • The Item keyword is not required. For example, in the request at the start of the NamedArraylist class, %alist('Idle') = 'Eric', for instance, is equivalent to:

    %alist:Item('Idle') = 'Eric'

  • As shown in the example at the start of the NamedArraylist class, NamedArraylist items are ordered alphabetically by their names. Accordingly, the Item method takes a name argument string.

See also

  • The ItemByNumber method, lets you retrieve or set an item using its item number.