Item (UnicodeNamedArraylist property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "<span style="font-size:120%; color:black"><b><section begin=dpl_desc/>Value of named item<section end=dpl_desc/></b></span> [[Category:UnicodeNamedArraylist methods|Item property...")
 
mNo edit summary
 
(22 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<span style="font-size:120%; color:black"><b><section begin=dpl_desc/>Value of named item<section end=dpl_desc/></b></span>
{{Template:UnicodeNamedArraylist:Item subtitle}}
[[Category:UnicodeNamedArraylist methods|Item property]]
<!--DPL?? Category:UnicodeNamedArraylist methods|Item property: Value of named item-->
<!-- This is very close to the same method's page for these classes:
<p>
      NamedArraylist
Item is a member of the [[UnicodeNamedArraylist class]].
      FloatNamedArraylist
    Many changes should be reflected to all three method's pages -->
<var>Item</var> is a ReadWrite property which returns or sets the value of the item that has the given name in the <var>UnicodeNamedArraylist</var>.
For additional comments about the <var>Item</var> method in collections, see [[Collections#Coding considerations for collections|"Coding considerations for collections"]].
==Syntax==
{{Template:UnicodeNamedArraylist:Item syntax}}
===Syntax terms===
<!-- This is very close to the same method's page for these classes:
      NamedArraylist
      FloatNamedArraylist
    Many changes should be reflected to all three method's pages -->
<table class="syntaxTable">
<tr><th>%currentItem</th>
<td>A variable of the same type as specified on the <var class="term">uniNal</var> declaration to contain the value of the specified <var class="term">uniNal</var> item.</td></tr>
<tr><th>uniNal</th>
<td>A <var>UnicodeNamedArraylist</var> object. </td></tr>
<tr><th>unicode</th>
<td>A Unicode string that serves as a subscript to identify a <var class="term">uniNal</var> item.</td></tr>
<tr><th>newItem</th>
<td>A value of the same type as specified on the <var class="term">uniNal</var> declaration to be assigned to the specified <var class="term">uniNal</var> item. </td></tr>
</table>
==Usage notes==
<!-- This is very close to the same method's page for these classes:
      NamedArraylist
      FloatNamedArraylist
    Many changes should be reflected to all three method's pages -->
<ul>
<li>The <var>Item</var> keyword is not required.  For example, in the first of the [[UnicodeNamedArraylist class#Examples|"Examples"]] on the <var>UnicodeNamedArraylist</var> class page, the following statement:
<p class="code">%k('&amp;sect;Apr':u) = 'Leo'</p>
is equivalent to:
<p class="code">%k:Item('&amp;sect;Apr':u) = 'Leo'
</p>
</p>
 
<li>If the <var>Item</var> property is being set and there is already an item on the <var>UnicodeNamedArraylist</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>UnicodeNamedArraylist</var> that has the indicated name, the item is added.
This ReadWrite property returns or sets the value of the item that has the
<li>If the <var>Item</var> property is being retrieved and there is no item on the <var>UnicodeNamedArraylist</var> that has the indicated name, the result is one of the following actions:
specified subscript name in the UnicodeNamedArraylist.
 
For additional comments about the Item method in collections,
see [[Collections#Coding considerations for collections|Coding considerations for collections]].
==Syntax==
  %item = %unamrayl:Item(name)
 
  %unamrayl:Item(name) = %item
===Syntax Terms===
<dl>
<dt><i>%item</i>
<dd>A variable of the same
type as specified on the ''%unamrayl'' declaration
to contain the value of the specified ''%unamrayl'' item.
Or a variable or value of the same
type as specified on the ''%unamrayl'' declaration
to be assigned to the specified ''%unamrayl'' item.
<dt><i>%unamrayl</i>
<dd>A UnicodeNamedArraylist object.
<dt><i>name</i>
<dd>A Unicode string that serves as a subscript to identify
a ''%unamrayl'' item.
 
</dl>
==Usage Notes==
<ul>
<ul>
<li>The <tt>Item</tt> keyword is not required.
<li>If the <var>[[UseDefault (UnicodeNamedArraylist property)|UseDefault]]</var> property value is <code>False</code>:
For example, in the request in the
[[UnicodeNamedArraylist class]] example, <tt>%k('&amp;sect;Apr':u) = 'Leo'</tt>, for
instance, is equivalent to:
<pre style="xmp">
    %k:Item('&amp;sect;Apr':u) = 'Leo'
</pre>
<li>If the Item property is being set and there is already an item
on the UnicodeNamedArraylist that has the specified name, that item is replaced.
 
If the Item property is being set and there is no item on the UnicodeNamedArraylist
that has the indicated name, the item is added.
 
If the Item property is being retrieved and there is no item on the UnicodeNamedArraylist
that has the indicated name, the result is one of the following actions:
<ul>
<ul>
<li>The request is cancelled if the
<li>Under <var>Sirius Mods</var> version 8.0 and later an <var>[[ItemNotPresent class|ItemNotPresent exception]]</var> is thrown.
[[UseDefault (UnicodeNamedArraylist property)|UseDefault]] property value is <tt>False</tt>.
<li>Under <var>Sirius Mods</var> version 7.9 and earlier the request is cancelled.
<li>The [[Default (UnicodeNamedArraylist property)|Default]] value is returned if the
</ul>
UseDefault property is <tt>True</tt>.
<li>The <var>[[Default (UnicodeNamedArraylist property)|Default]]</var> value is returned if the <var>UseDefault</var> property is <code>True</code>.
</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 (UnicodeNamedArraylist function)|Number]]</var> function, for example:
<p class="code">%num = %myLis:number(%key)
if %num then %name = %myLis:[[ItemByNumber (UnicodeNamedArraylist property)|itemByNumber]](%num)
...
</p>
<li>As shown in the first of the [[UnicodeNamedArraylist class#Examples|"Examples"]] on the <var>UnicodeNamedArraylist</var> class page,
<var>UnicodeNamedArraylist</var> items are ordered alphabetically by their subscript names.
</ul>
</ul>
<li>As shown in the example in the [[UnicodeNamedArraylist class]] article,
UnicodeNamedArraylist items are ordered alphabetically by their subscript names.
==See also==
Accordingly, the Item method takes a Unicode string ''name'' argument.
The ItemByNumber method, described below,
<!-- This is very close to the same method's page for these classes:
lets you retrieve or set an item using the item's ordinal number.
      NamedArraylist
The [[NameByNumber (UnicodeNamedArraylist property)|NameByNumber]] function
      FloatNamedArraylist
lets you retrieve or set an item using the item's subscript name.
    Many changes should be reflected to all three method's pages -->
<ul><li>The <var>[[ItemByNumber_(GenericNamedArraylist_property)|ItemByNumber]]</var> property lets you retrieve or set an item using the item's ordinal number.
<li>The <var>[[NameByNumber (UnicodeNamedArraylist function)|NameByNumber]]</var> function lets you retrieve an item's name using the item's ordinal number.
<li>The <var>[[Number (UnicodeNamedArraylist function)|Number]]</var> function lets you retrieve an item's ordinal number using the item's name; it can be useful for determining whether an item exists for a specified name.
</ul>
</ul>
{{Template:UnicodeNamedArraylist:Item footer}}

Latest revision as of 16:44, 5 August 2012

Value of named item (UnicodeNamedArraylist class)


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

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

Syntax

%currentItem = uniNal:Item( unicode) uniNal:Item( unicode) = newItem Throws ItemNotPresent

Syntax terms

%currentItem A variable of the same type as specified on the uniNal declaration to contain the value of the specified uniNal item.
uniNal A UnicodeNamedArraylist object.
unicode A Unicode string that serves as a subscript to identify a uniNal item.
newItem A value of the same type as specified on the uniNal declaration to be assigned to the specified uniNal item.

Usage notes

  • The Item keyword is not required. For example, in the first of the "Examples" on the UnicodeNamedArraylist class page, the following statement:

    %k('&sect;Apr':u) = 'Leo'

    is equivalent to:

    %k:Item('&sect;Apr':u) = 'Leo'

  • If the Item property is being set and there is already an item on the UnicodeNamedArraylist that has the specified name, that item is replaced. If the Item property is being set and there is no item on the UnicodeNamedArraylist that has the indicated name, the item is added.
  • If the Item property is being retrieved and there is no item on the UnicodeNamedArraylist that has the indicated name, the result is one of the following actions:
    • If the UseDefault property value is False:
      • Under Sirius Mods version 8.0 and later an ItemNotPresent exception is thrown.
      • Under Sirius Mods version 7.9 and earlier the request is cancelled.
    • 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) ...

  • As shown in the first of the "Examples" on the UnicodeNamedArraylist class page, UnicodeNamedArraylist items are ordered alphabetically by their subscript names.

See also

  • The ItemByNumber property lets you retrieve or set an item using the item's ordinal number.
  • The NameByNumber function lets you retrieve an item's name using the item's ordinal number.
  • The Number function lets you retrieve an item's ordinal number using the item's name; it can be useful for determining whether an item exists for a specified name.