New (CharacterMap constructor): Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (→Usage notes) |
||
Line 31: | Line 31: | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>As described in [[Object variables#Using New or other Constructors|"Using New or other Constructors"]], <var>New</var> can be invoked with no object, with an explicit class name, or with an object variable in the class, even if that object is <var>Null</var>:<p class="code">%charMap = new | <li>As described in [[Object variables#Using New or other Constructors|"Using New or other Constructors"]], <var>New</var> can be invoked with no object, with an explicit class name, or with an object variable in the class, even if that object is <var>Null</var>:<p class="code">%charMap = new(in='A', out='-') | ||
%charMap = %(CharacterMap):new | %charMap = %(CharacterMap):new(in='A', out='-') | ||
%charMap = %charMap:new | %charMap = %charMap:new(in='A', out='-') | ||
</p> | </p> | ||
<li>Case is respected in all character specifications. | <li>Case is respected in all character specifications. | ||
Line 45: | Line 45: | ||
<li>For an example of a <var>New</var> method call, see the [[CharacterMap class#Example|CharacterMap class]] page. | <li>For an example of a <var>New</var> method call, see the [[CharacterMap class#Example|CharacterMap class]] page. | ||
</ul> | </ul> | ||
==See also== | ==See also== | ||
{{Template:CharacterMap:New footer}} | {{Template:CharacterMap:New footer}} |
Revision as of 21:21, 27 July 2011
Create CharacterMap object (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
%characterMap | A CharacterMap object variable. |
---|---|
%(CharacterMap) | The optional class name in parentheses denotes a Constructor. See "Usage notes", below, for more information about invoking a CharacterMap Constructor. |
In | 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 | An optional, name required, argument that specifies the "output table" characters. Out may not be longer than In; it may be shorter, however, as long as a pad character is specified. Out may not be more than 256 characters. |
Pad | An optional, name required, argument that specifies the character used to pad the output table string on the right if it is shorter than In.
Pad must be a single character, only. |
Usage notes
- As described in "Using New or other Constructors", New can be invoked with no object, with an explicit class name, or with an object variable in the class, even if that object is Null:
%charMap = new(in='A', out='-') %charMap = %(CharacterMap):new(in='A', out='-') %charMap = %charMap:new(in='A', out='-')
- 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.