MarksStoreArray class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Created page with "A <var>MarksStoreArray</var> class object contains a mapping of characters to characters. Each character in an In string (the “input table”) is associated with, or ma...")
 
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
A <var>MarksStoreArray</var> class object contains a mapping of characters to characters.
The <var>MarksStoreArray</var> class was written for [http://en.wikipedia.org/wiki/Marks_%26_Spencer Marks and Spencer] a UK retailer. The index for <var>MarksStoreArray</var> items is a a three-digit Marks and Spencer store code so is not likely to be useful to anyone other than Marks and Spencer.
Each character in an In string
 
(the &ldquo;input table&rdquo;) is associated with, or mapped to, an individual character
The <var>MarksStoreArray</var> class is a limited collection class &mdash; the declaration of a <var>MarksStoreArray</var> variable requires an <var>Of</var> clause follow by a datatype, where the datatype can only be a <var>String</var>, <var>Float</var>, or <var>Fixed</var> datatype. As such, it is considerably less useful than the [[NamedArraylist class]]. It's main advantage over <var>NamedArraylists</var> is that all collection items are stored in STBL so that the access path for a <var>MarksStoreArray</var> object is very efficient, indeed, and so can be useful in situations where there is heavy access to lots of different string or numeric values, based on frequently changing store codes.
from an Out string (the &ldquo;output table&rdquo;).
 
The output table may be supplemented with instances of a pad character
However, if the items in a collection are, themselves, objects the <var>MarksStoreArray</var> cannot be used and, instead, a <var>NamedArrayList</var> should be used, with the store codes as the "names" (index values).
to ensure a one-to-one mapping with the input table characters.
[[List of MarksStoreArray methods]] lists all the methods in this class.
[[List of CharacterMap methods]] lists all the methods in this class.
CharacterMap includes a constructor, copy methods, and an update method
for modifying the map.
===Example===
===Example===
Most of these methods are shown in the following example,
The following example sets the value of an item associated with store code <code>ABC</code> to 22:
which features the intrinsic String [[Translate (String function)|Translate]] function.
 
In the example, a new CharacterMap is the argument for the Translate method;
<p class="code">begin
then that map is copied and modified, and the modified map is used in a
%quantity  is collection marksStoreArray of float
second Translate call:
 
%quantity = new
%quantity('ABC') = 22


    begin
end
    %map is object characterMap
</p>
    %map2 is object characterMap
    %ls is longstring
    %map = New(in='x-', out='!c')
    %ls = 'xu--exx'
    [[Targeted Text statements|printtext]] {~} = '{%ls:translate(%map)}'
    %map2 = %map:Copy
    %map2:Update(in='x',out='s')
    printtext {~} = '{%ls:translate(%map2)}'
    end


The result is:
<pre>
    %ls:translate(%map) = '!ucce!!'
    %ls:translate(%map2) = 'success'
</pre>
This class is new as of version 7.3 of the ''Sirius Mods''.
[[Category:System classes]]
[[Category:System classes]]

Latest revision as of 19:46, 4 February 2011

The MarksStoreArray class was written for Marks and Spencer a UK retailer. The index for MarksStoreArray items is a a three-digit Marks and Spencer store code so is not likely to be useful to anyone other than Marks and Spencer.

The MarksStoreArray class is a limited collection class — the declaration of a MarksStoreArray variable requires an Of clause follow by a datatype, where the datatype can only be a String, Float, or Fixed datatype. As such, it is considerably less useful than the NamedArraylist class. It's main advantage over NamedArraylists is that all collection items are stored in STBL so that the access path for a MarksStoreArray object is very efficient, indeed, and so can be useful in situations where there is heavy access to lots of different string or numeric values, based on frequently changing store codes.

However, if the items in a collection are, themselves, objects the MarksStoreArray cannot be used and, instead, a NamedArrayList should be used, with the store codes as the "names" (index values). List of MarksStoreArray methods lists all the methods in this class.

Example

The following example sets the value of an item associated with store code ABC to 22:

begin %quantity is collection marksStoreArray of float %quantity = new %quantity('ABC') = 22 end