UnicodeNamedArraylist class

From m204wiki
Revision as of 21:28, 4 January 2011 by Dme (talk | contribs) (Created page with "<!-- UnicodeNamedArraylist class --> The UnicodeNamedArraylist class is nearly identical to the NamedArraylist class. The main difference is that instead of EBCDIC subscript name...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The UnicodeNamedArraylist class is nearly identical to the NamedArraylist class. The main difference is that instead of EBCDIC subscript names for items as in the NamedArraylist class, the name subscripts in a UnicodeNamedArraylist object are Unicode values. UnicodeNamedArraylist items are stored by item name in Unicode order, whereas NamedArraylist items are stored by item name in EBCDIC order.

UnicodeNamedArraylists were added in Sirius Mods version 7.6. Note: The names of UnicodeNamedArraylists are limited to 127 characters (versus 255 bytes for NamedArraylists).

The following annotated request demonstrates the methods where the distinction between a UnicodeNamedArraylist and a NamedArraylist is significant. The U constant function handily creates Unicode strings in the item name subscripts. Those names also begin with an XHTML entity reference, which is further discussed ?? reftxt=* refid=entrefs..

   b

   %i  is float
   %k  is unicodeNamedArraylist of longstring
   %m  is Arraylist of longstring
   %k = new

   * implicit Item method sets list item values:
   %k('&sect;Jan':u) = 'Orion'
   %k('&sect;Apr':u) = 'Leo'
   %k('&sect;Mar':u) = 'Cancer'
   %k('&sect;Jun':u) = 'Ursa Minor'
   %k('&sect;Nov':u) = 'Andromeda'
   %k('&sect;Dec':u) = 'Aries'
   %k('&sect;Feb':u) = 'Canis Major'

   * print the value of the item whose name is the
   * Item method argument:
   print %k:Item('&sect;Jan':u)

   * print item number of named item:
   print %k:number('&sect;Nov':u)

   * print name of each list item, in order of item position
   * from first to last:
   for %i from 1 to %k:count
      print %i ': ' %k:nameByNumber(%i)
   end for

   * how many items remain after specified item is removed?
   printText {~} = {%k:removeItem('&sect;Dec':u)}

   * names and values of list items in order by item position:
   for %i from 1 to %k:count
      print %k:nameByNumber(%i) ': ' and %k:itembyNumber(%i)
   end for

   * sort list values alphabetically in descending order
   %m = %k:sortNew(descending(this))
   %m:print

   end

The request prints:

    Orion
    7
    1: &sect.Apr
    2: &sect.Dec
    3: &sect.Feb
    4: &sect.Jan
    5: &sect.Jun
    6: &sect.Mar
    7: &sect.Nov
    %k:removeItem('&sect;Dec':u) = 6
    &sect.Apr:  Leo
    &sect.Feb:  Canis Major
    &sect.Jan:  Orion
    &sect.Jun:  Ursa Minor
    &sect.Mar:  Cancer
    &sect.Nov:  Andromeda
    1: Ursa Minor
    2: Orion
    3: Leo
    4: Canis Major
    5: Cancer
    6: Andromeda

For background information about collections and about declaring collection object variables, see Collections. See also Coding considerations for collections.

The individual UnicodeNamedArraylist methods are described in the following subsections. In the method templates, %unamrayl is used to represent the object to which the method is being applied, sometimes called the “method object” or the “method UnicodeNamedArraylist.” Additional conventions are described in Notation conventions for methods.