CharacterMap class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 8: Line 8:
The [[List of CharacterMap methods|"List of CharacterMap methods"]] lists all the methods in this class.
The [[List of CharacterMap methods|"List of CharacterMap methods"]] lists all the methods in this class.
   
   
CharacterMap includes a constructor, copy methods, and an update method
<var>CharacterMap</var> includes a constructor, copy methods, and an update method
for modifying the map.
for modifying the map.
This class is new as of version 7.3 of the <var class="product">Sirius Mods</var>.
===Example===
===Example===
Most of these methods are shown in the following example,
Most of these methods are shown in the following example,
which features the intrinsic <var>String</var> function, <var>[[Translate (String function)|Translate]]</var>.
which features the intrinsic <var>String</var> function, <var>[[Translate (String function)|Translate]]</var>.
In the example, a new CharacterMap is the argument for the Translate method;
In the example, a new <var>CharacterMap</var> is the argument for the <var>Translate method</var>;
then that map is copied and modified, and the modified map is used in a
then that map is copied and modified, and the modified map is used in a
second Translate call:
second <var>Translate</var> call:
 
<p class="code">begin
    begin
%map is object characterMap
    %map is object characterMap
%map2 is object characterMap
    %map2 is object characterMap
%ls is longstring
    %ls is longstring
   
   
    %map = New(in='x-', out='!c')
%map = New(in='x-', out='!c')
    %ls = 'xu--exx'
%ls = 'xu--exx'
    [[Targeted Text statements|printtext]] {~} = '{%ls:translate(%map)}'
[[Targeted Text statements|printtext]] {~} = '{%ls:translate(%map)}'
   
   
    %map2 = %map:Copy
%map2 = %map:Copy
    %map2:Update(in='x',out='s')
%map2:Update(in='x',out='s')
    printtext {~} = '{%ls:translate(%map2)}'
printtext {~} = '{%ls:translate(%map2)}'
   
   
    end
end </p>


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

Revision as of 00:08, 1 December 2011

A CharacterMap object contains a mapping of characters to characters. Each character in an In string (the “input table”) is associated with, or mapped to, an individual character from an Out string (the “output table”). The output table may be supplemented with instances of a pad character to ensure a one-to-one mapping with the input table characters.

The "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.

This class is new as of version 7.3 of the Sirius Mods.

Example

Most of these methods are shown in the following example, which features the intrinsic String function, Translate. In the example, a new CharacterMap is the argument for the Translate method; then that map is copied and modified, and the modified map is used in a second Translate call:

begin %map is object characterMap %map2 is object characterMap %ls is longstring %map = New(in='x-', out='!c') %ls = 'xu--exx' printtext {~} = '{%ls:translate(%map)}' %map2 = %map:Copy %map2:Update(in='x',out='s') printtext {~} = '{%ls:translate(%map2)}' end

The result is:

%ls:translate(%map) = '!ucce!!' %ls:translate(%map2) = 'success'