UnicodeSubstring (Unicode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (syntax terms, tags and links)
m (align with revised syntax template)
Line 1: Line 1:
{{Template:Unicode:UnicodeSubstring subtitle}}
{{Template:Unicode:UnicodeSubstring subtitle}}
<var>UnicodeSubstring</var> returns a specific number of characters starting at a specific position in the method object <var>Unicode</var> string, possibly padding it on the right.
<var>UnicodeSubstring</var> returns a specific number of characters starting at a specific position in the method object <var>Unicode</var> string, possibly padding it on the right.


Line 11: Line 10:
<tr><th>unicode</th>
<tr><th>unicode</th>
<td>A <var>Unicode</var> string. </td></tr>
<td>A <var>Unicode</var> string. </td></tr>
<tr><th>start</th>
<tr><th>position</th>
<td>The character position in the method object that is the starting point of the substring that is returned. The first character from the left in the method object is position <tt>1</tt>. </td></tr>
<td>The character position in the method object that is the starting point of the substring that is returned. The first character from the left in the method object is position <code>1</code>.</td></tr>
<tr><th>length</th>
<tr><th>length</th>
<td>The number of characters to return. If the method object has fewer characters than the requested number of characters (starting at the <var class="term">start</var> position), it is either padded to the requested length, or the entire method object starting at the <var class="term">start</var> position is returned with no padding, depending on the value of the <var class="term">pad</var> parameter. </td></tr>
<td>The number of characters to return. If the method object has fewer characters than the requested number of characters (starting at the <var class="term">position</var>), it is either padded to the requested <var class="term">length</var>, or the entire method object starting at the <var class="term">position</var> is returned with no padding, depending on the value of the <var class="term">Pad</var> parameter. </td></tr>
<tr><th>pad</th>
<tr><th>Pad</th>
<td>The character used to pad the result string on the right if it is shorter than the requested length. <var class="term">Pad</var> defaults to the null string (<code><nowiki>''</nowiki></code>), which means no padding is done. <var class="term">Pad</var> is a <var>[[Methods#Named parameters|Name-Required]]</var> parameter.</td></tr>
<td>The character used to pad the result string on the right if it is shorter than the requested length. <var class="term">Pad</var> defaults to the null string (<code><nowiki>''</nowiki></code>), which means no padding is done. <var class="term">Pad</var> is a <var>[[Methods#Named parameters|Name-Required]]</var> parameter.</td></tr>
</table>
</table>

Revision as of 06:05, 25 February 2011

Return a substring of the method object string (Unicode class)

UnicodeSubstring returns a specific number of characters starting at a specific position in the method object Unicode string, possibly padding it on the right.

Syntax

%outUnicode = unicode:UnicodeSubstring( position, [length], [Pad= c])

Syntax terms

%outUnicode A Unicode variable to receive the result of the UnicodeSubstring method.
unicode A Unicode string.
position The character position in the method object that is the starting point of the substring that is returned. The first character from the left in the method object is position 1.
length The number of characters to return. If the method object has fewer characters than the requested number of characters (starting at the position), it is either padded to the requested length, or the entire method object starting at the position is returned with no padding, depending on the value of the Pad parameter.
Pad The character used to pad the result string on the right if it is shorter than the requested length. Pad defaults to the null string (''), which means no padding is done. Pad is a Name-Required parameter.

Usage notes

  • The length must be a non-negative number. A negative length results in request cancellation.
  • The pad parameter must be either null or a single character. A longer value results in a compilation error.
  • If the start position is known to be 1, it might be tidier and slightly more efficient to use the UnicodeLeft method instead of UnicodeSubstring.
  • UnicodeSubstring method is analogous to the intrinsic String method: Substring.
  • UnicodeSubstring function is available as of "Sirius Mods" Version 7.5.

Examples

  1. The following statement places into %y the 5 characters of %x starting at the third character. If %x is shorter than 7 characters, then all of %x is copied into %y:

    %y = %x:unicodeSubstring(3, 5)

  2. The following statement displays C?!:

    %u is unicode initial('ABC&#xA1;':U) printText {%u:unicodeSubstring(3,3, pad='!')}

    The question mark in the result represents a valid EBCDIC character that is not displayable.

See also