UnicodeSubstring (Unicode function): Difference between revisions
m (1 revision) |
m (1 revision) |
||
Line 2: | Line 2: | ||
[[Category:Unicode methods|UnicodeSubstring function]] | [[Category:Unicode methods|UnicodeSubstring function]] | ||
[[Category:Intrinsic methods]] | [[Category:Intrinsic methods]] | ||
<!--DPL?? Category:Unicode methods|<var>UnicodeSubstring</var> function: Substring at specifed of string to specified length--> | <!--DPL?? Category:<var>Unicode</var> methods|<var>UnicodeSubstring</var> function: Substring at specifed of string to specified length--> | ||
<!--DPL?? Category:Intrinsic methods|<var>UnicodeSubstring</var> (Unicode function): Substring at specifed of string to specified length--> | <!--DPL?? Category:Intrinsic methods|<var>UnicodeSubstring</var> (<var>Unicode</var> function): Substring at specifed of string to specified length--> | ||
<!--DPL?? Category:System methods|<var>UnicodeSubstring</var> (Unicode function): Substring at specifed of string to specified length--> | <!--DPL?? Category:<var>System</var> methods|<var>UnicodeSubstring</var> (<var>Unicode</var> function): Substring at specifed of string to specified length--> | ||
This function returns a specific number of characters starting at a | This function returns a specific number of characters starting at a | ||
specific position in the method object Unicode string, | specific position in the method object <var>Unicode</var> string, | ||
possibly padding it on the right. | possibly padding it on the right. | ||
Line 16: | Line 16: | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th><i>%outUni</i></th> | <tr><th><i>%outUni</i></th> | ||
<td>A Unicode variable to receive the result of the <var>UnicodeSubstring</var> method. </td></tr> | <td>A <var>Unicode</var> variable to receive the result of the <var>UnicodeSubstring</var> method. </td></tr> | ||
<tr><th><i>unicode</i></th> | <tr><th><i>unicode</i></th> | ||
<td>A Unicode string. </td></tr> | <td>A <var>Unicode</var> string. </td></tr> | ||
<tr><th><i>start</i></th> | <tr><th><i>start</i></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 <tt>1</tt>. </td></tr> | ||
Line 33: | Line 33: | ||
A longer value results in a compilation error. | A longer value results in a compilation error. | ||
<li>If the starting position is known to be 1, it might be tidier and | <li>If the starting position is known to be 1, it might be tidier and | ||
slightly more efficient to use the | slightly more efficient to use the <var>Unicode</var>Left method instead of <var>UnicodeSubstring</var>. | ||
<li>The <var>UnicodeSubstring</var> method is analogous to | <li>The <var>UnicodeSubstring</var> method is analogous to | ||
the String intrinsic [[Substring (String function)|Substring]] method. | the <var>String</var> intrinsic [[Substring (String function)|Substring]] method. | ||
</ul> | </ul> | ||
==Examples== | ==Examples== |
Revision as of 15:49, 20 January 2011
Return a substring of the method object string (Unicode class)
This function returns a specific number of characters starting at a specific position in the method object Unicode string, possibly padding it on the right.
The UnicodeSubstring function is available as of version 7.5 of the Sirius Mods.
Syntax
%outUnicode = unicode:UnicodeSubstring( position, [length], [Pad= c])
Syntax terms
%outUni | A Unicode variable to receive the result of the UnicodeSubstring method. |
---|---|
unicode | A Unicode string. |
start | 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 start position), it is either padded to the requested length, or the entire method object starting at the start position is returned with no padding, depending on the value of the pad parameter. |
Pad=char | The character used to pad the result string on the right if it is shorter than the requested length. char defaults to a null, which means no padding is done. Pad is a name-required parameter. |
Usage notes
- The length must be a non-negative number. A negative number 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 starting position is known to be 1, it might be tidier and slightly more efficient to use the UnicodeLeft method instead of UnicodeSubstring.
- The UnicodeSubstring method is analogous to the String intrinsic Substring method.
Examples
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)
The following statement displays C?!:
%u is unicode initial('ABC¡':U) printText {%u:unicodeSubstring(3,3, pad='!')}
The question mark in the result represents a valid EBCDIC character that is not displayable. The U constant function used in the example is described ??U. For information about the PrintText statement, see the list item ?? refid=intprnt..