Substring (StringTokenizer function): Difference between revisions
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
{{Template:StringTokenizer:Substring subtitle}} | |||
This function returns a substring | This function returns a substring | ||
Line 12: | Line 6: | ||
The substring may be padded on the right. | The substring may be padded on the right. | ||
==Syntax== | |||
{{Template:StringTokenizer:Substring syntax}} | |||
===Syntax terms=== | ===Syntax terms=== | ||
<dl> | <dl> | ||
Line 36: | Line 29: | ||
</dl> | </dl> | ||
==Usage notes== | |||
<ul> | <ul> | ||
<li>The length must be a non-negative number. | <li>The length must be a non-negative number. | ||
Line 45: | Line 38: | ||
error in ''Sirius Mods'' 7.3 and higher. | error in ''Sirius Mods'' 7.3 and higher. | ||
</ul> | </ul> | ||
==Examples== | |||
The following request prints | The following request prints "<tt>nizer Substring example!!!!!</tt>": | ||
<pre> | <pre> | ||
begin | begin | ||
Line 57: | Line 50: | ||
end | end | ||
</pre> | </pre> | ||
==See also== | |||
{{Template:StringTokenizer:Substring footer}} |
Revision as of 19:54, 6 February 2011
Specified substring within tokenizing string (StringTokenizer class)
This function returns a substring
that is a specified length and starts at a specific position in the
tokenizing string.
The substring may be padded on the right.
Syntax
%string = stringTokenizer:Substring( position, length, [Pad= c])
Syntax terms
- %string
- A string variable to contain the returned substring.
- %tok
- A StringTokenizer object variable.
- start
- The starting byte number in the tokenizing string to return.
- length
- The number of bytes to return. If the tokenizing string has fewer characters than the requested bytes (starting at the start position), it is either padded to the requested length, or the entire tokenizing string 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 substring on the right if the result 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 request cancellation in Sirius Mods version 7.2 and in a compilation error in Sirius Mods 7.3 and higher.
Examples
The following request prints "nizer Substring example!!!!!":
begin %tok is object stringtokenizer %tok = new %tok:string = 'a tokenizer Substring example' %sub = %tok:substring(7, 28, pad='!') printText {~} is {%tok:substring(7, 28, pad='!')} end