Item (NamedArraylist property): Difference between revisions
Jump to navigation
Jump to search
m (match syntax table to diagram, lots of tags, some edits) |
m (→Usage notes) |
||
Line 26: | Line 26: | ||
<li>The <var>[[Default (NamedArraylist property)|Default]]</var> value is returned if the <var>UseDefault</var> property is <code>True</code>. | <li>The <var>[[Default (NamedArraylist property)|Default]]</var> value is returned if the <var>UseDefault</var> property is <code>True</code>. | ||
</ul> | </ul> | ||
Regardless of the value of <var>UseDefault</var>, the presence of the item with the indicated name can be checked using the <var>[[Number (NamedArraylist function)|Number]]</var> function, for example: | |||
<p class="code">%num = %myLis:number(%key) | |||
if %num then %name = %myLis:[[ItemByNumber (NamedArraylist property)|itemByNumber]](%num) | |||
... | |||
</p> | |||
<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: | <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: | ||
<p class="code">%alist:Item('Idle') = 'Eric' | <p class="code">%alist:Item('Idle') = 'Eric' |
Revision as of 20:02, 21 July 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
.
Regardless of the value of UseDefault, the presence of the item with the indicated name can be checked using the Number function, for example:
%num = %myLis:number(%key) if %num then %name = %myLis:itemByNumber(%num) ...
- The request is cancelled if the UseDefault property value is
- 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.