Item (FloatNamedArraylist property): Difference between revisions

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

Latest revision as of 16:42, 5 August 2012

Value of named item (FloatNamedArraylist class)


Item is a ReadWrite property which returns or sets the value of the item that has the specified subscript number in the FloatNamedArraylist.

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

Syntax

%currentItem = fltNal:Item( number) fltNal:Item( number) = newItem Throws ItemNotPresent

Syntax terms

%currentItem A variable of the same type as specified on the fltNal declaration to contain the value of the specified fltNal item.
fltNal A FloatNamedArraylist object.
number A number that serves as a subscript to identify a fltNal item.
newItem A value of the same type as specified on the fltNal declaration to be assigned to the specified fltNal item.

Usage notes

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

    %y(7) = 'seven'

    is equivalent to:

    %y:item(7) = 'seven'

  • If the Item property is being set and there is already an item on the FloatNamedArraylist that has the specified subscript, that item is replaced. If the Item property is being set and there is no item on the FloatNamedArraylist that has the indicated subscript, the item is added.
  • If the Item property is being retrieved and there is no item on the FloatNamedArraylist that has the indicated subscript, 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 FloatNamedArraylist class page, FloatNamedArraylist items are ordered numerically by their subscript numbers.

See also

  • The ItemByNumber property lets you retrieve or set an item using the item's ordinal number.
  • The NameByNumber function lets you retrieve the "name" (numerical subscript) of the item that has the specified item number (position) .
  • The Number function lets you retrieve an item's ordinal number using the item's subscript number; it can be useful for determining whether an item exists for a specified subscript number.