Item (UnicodeNamedArraylist property)

From m204wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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('§Apr':u) = 'Leo'

    is equivalent to:

    %k:Item('§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.