Item (NamedArraylist property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 12: Line 12:
see [[Collections#Coding considerations for collections|Coding considerations for collections]].
see [[Collections#Coding considerations for collections|Coding considerations for collections]].
==Syntax==
==Syntax==
  %item = %namrayl:Item(name)
<p class="code">%item = %namrayl:Item(name)


  %namrayl:Item(name) = %item
%namrayl:Item(name) = %item
</p>
===Syntax Terms===
===Syntax Terms===
<dl>
<dl>
Line 50: Line 51:
[[NamedArraylist class]], <tt>%alist('Idle') = 'Eric'</tt>, for instance,
[[NamedArraylist class]], <tt>%alist('Idle') = 'Eric'</tt>, for instance,
is equivalent to:
is equivalent to:
<pre style="xmp">
<p class="code">%alist:Item('Idle') = 'Eric'
    %alist:Item('Idle') = 'Eric'
</p>
</pre>
<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]],
NamedArraylist items are ordered alphabetically by their names.
NamedArraylist items are ordered alphabetically by their names.

Revision as of 20:55, 28 January 2011

<section begin=dpl_desc/>Value of named item<section end=dpl_desc/>

Item is a member of the NamedArraylist class.

This 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

%item = %namrayl:Item(name) %namrayl:Item(name) = %item

Syntax Terms

%item
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.
%namrayl
A NamedArraylist object.
name
A string that serves as a subscript to identify a %namrayl 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. The ItemByNumber method, described below, lets you retrieve or set an item using its item number.