New (CharacterMap constructor): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (Undo revision 6092 by Wiccan (talk))
Line 8: Line 8:


The New method creates a character map, which associates individual
The New method creates a character map, which associates individual
characters from an In string (the "input table") with the characters
characters from an In string (the “input table”) with the characters
in the corresponding position in the "output table".
in the corresponding position in the “output table”.
The output table consists of the characters in the Out string (plus copies of
The output table consists of the characters in the Out string (plus copies of
the Pad character, if necessary).
the Pad character, if necessary).
Line 15: Line 15:
{{Template:CharacterMap:New syntax}}
{{Template:CharacterMap:New syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntax">
<dl>
<th>%map</th>
<dt><i>%map</i>
<td>A CharacterMap object variable.</td>
<dd>A CharacterMap object variable.
<th>In=string</th>
<dt><b>In=</b><i>string</i>
<td>A required, name required, argument that specifies the "input table"
<dd>A required, name required, argument that specifies the &ldquo;input table&rdquo;
characters in the mapping.
characters in the mapping.


No character duplications are allowed in the In string, which
No character duplications are allowed in the In string, which
may not be more than 256 characters.</td>
may not be more than 256 characters.
<th>Out=string</th>
<dt><b>Out=</b><i>string</i>
<td>An optional, name required, argument that specifies the "output table"
<dd>An optional, name required, argument that specifies the &ldquo;output table&rdquo;
characters.
characters.


The Out string may not be longer than the In string; it may be shorter, however,
The Out string may not be longer than the In string; it may be shorter, however,
as long as a Pad character is specified.
as long as a Pad character is specified.
The Out string may not be more than 256 characters.</td>
The Out string may not be more than 256 characters.
<th>Pad=char</th>
<dt><b>Pad=</b><i>char</i>
<td>An optional, name required, argument that specifies the character used
<dd>An optional, name required, argument that specifies the character used
to pad the output table string on the right if it is shorter than the In string.
to pad the output table string on the right if it is shorter than the In string.


''char'' must be a single character, only.
''char'' must be a single character, only.
</td>
 
</table>
</dl>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>Case is respected in all character specifications.
<li>Case is respected in all character specifications.
<li>If the In string is longer than the Out string, the "extra" In
<li>If the In string is longer than the Out string, the &ldquo;extra&rdquo; In
characters are associated with the Pad character.
characters are associated with the Pad character.
In this case, it is a request-canceling error if no Pad character is present.
In this case, it is a request-canceling error if no Pad character is present.

Revision as of 02:51, 16 January 2011

Create CharacterMap object (CharacterMap class)

New is a member of the CharacterMap class.

The New method creates a character map, which associates individual characters from an In string (the “input table”) with the characters in the corresponding position in the “output table”. The output table consists of the characters in the Out string (plus copies of the Pad character, if necessary).

Syntax

%characterMap = [%(CharacterMap):]New( In= string, [Out= string], [Pad= c])

Syntax terms

%map
A CharacterMap object variable.
In=string
A required, name required, argument that specifies the “input table” characters in the mapping. No character duplications are allowed in the In string, which may not be more than 256 characters.
Out=string
An optional, name required, argument that specifies the “output table” characters. The Out string may not be longer than the In string; it may be shorter, however, as long as a Pad character is specified. The Out string may not be more than 256 characters.
Pad=char
An optional, name required, argument that specifies the character used to pad the output table string on the right if it is shorter than the In string. char must be a single character, only.

Usage notes

  • Case is respected in all character specifications.
  • If the In string is longer than the Out string, the “extra” In characters are associated with the Pad character. In this case, it is a request-canceling error if no Pad character is present.
  • The Out argument can be omitted, as long as a Pad argument is present. The Pad argument has no default.
  • For an example of a New method call, see the CharacterMap class page.