After (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:String:After subtitle}}
{{Template:String:After subtitle}}
<var>After</var> operates on a string and returns the portion of that string after a user-specified delimiter.  To get the portion of the string before a delimiter, use the <var>[[Before (String function)|Before]]</var> string method.


This page is [[under construction]].
==Syntax==
==Syntax==
{{Template:String:After syntax}}
{{Template:String:After syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%outString</th><td>string</td></tr>
<tr><th nowrap>%outString</th>
<td>A <var>String</var> or <var>Longstring</var> variable. If a string is specified, it must be long enough to hold the resulting parsed string.  If the defined string is shorter than needed to hold the result, a request canceling error occurs.</td></tr>
 
<tr><th>string</th>
<tr><th>string</th>
<td>string</td></tr>
<td>A <var>String</var> or <var>Longstring</var> variable that holds the string to be parsed.</td></tr>
 
<tr><th>substring</th>
<tr><th>substring</th>
<td>string</td></tr>
<td>A <var>String</var> or <var>Longstring</var> variable that holds the separator character or characters on which parsing occurs.</td></tr>
 
<tr><th><var>Start</var></th>
<tr><th><var>Start</var></th>
<td>number<br/>This default value of this argument is [[??]].</td></tr>
<td>A number that is the starting point for parsing. The default value is 1, indicating the beginning of the string. This is a [[Notation_conventions_for_methods#Named_arguments|name allowed]] argument, and it cannot be 0. If you specify a value larger than the string, <var>After</var> returns a null string.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<li>If a starting value is specified, <var class="term">%outString</var> is the string content that begins after the first occurrence of the delimiter string encountered after the specified start value, and that ends at the end of the string.
The delimiter string is not a list of individual delimiters, but a single delimiter which may be multiple characters. In other words, if your delimiter is <code>ok</code>, <var>After</var> looks for occurrences of those two lowercase letters and returns a value after the first such occurrence that follows the start value. </li>
<li>This method is always case-sensitive. </li>
</ul>
==Examples==
==Examples==
The following string (note the initial blanks) is the result of the request displayed below it:
<p><code>&nbsp;&nbsp;I am the Walrus!  Koo Koo Kachoo!</code></p>
<p class="code">begin
  %x is string len 64 initial('I am the Eggman!  I am the Walrus!  Koo Koo Kachoo!')
  printText {%x:after('!')}
end
</p>
The following string is the result of the request displayed below it:
<p><code>&nbsp;&nbsp;Koo Koo Kachoo!</code></p>
<p class="code">begin
  %x is string len 64 initial('I am the Eggman!  I am the Walrus!  Koo Koo Kachoo!')
  printText {%x:after('!',start=20)}
end
</p>
The following request prints each blank-delimited word, one at a time:
<p class="code">begin
  %x is string len 64 initial('I am the Eggman!  I am the Walrus!  Koo Koo Kachoo!')
  repeat while %x:length
    print %x:before(' ')
    %x = %x:after(' ')
  end repeat
end
</p>
==See also==
==See also==
{{Template:String:After footer}}
<ul>
<li><var>[[Before (String function)|Before]]</var></li>
</ul>
{{Template:String:Before footer}}

Latest revision as of 20:02, 3 September 2015

Part of string after a substring (String class)

[Introduced in Model 204 7.5]

After operates on a string and returns the portion of that string after a user-specified delimiter. To get the portion of the string before a delimiter, use the Before string method.

Syntax

%outString = string:After( substring, [Start= number])

Syntax terms

%outString A String or Longstring variable. If a string is specified, it must be long enough to hold the resulting parsed string. If the defined string is shorter than needed to hold the result, a request canceling error occurs.
string A String or Longstring variable that holds the string to be parsed.
substring A String or Longstring variable that holds the separator character or characters on which parsing occurs.
Start A number that is the starting point for parsing. The default value is 1, indicating the beginning of the string. This is a name allowed argument, and it cannot be 0. If you specify a value larger than the string, After returns a null string.

Usage notes

  • If a starting value is specified, %outString is the string content that begins after the first occurrence of the delimiter string encountered after the specified start value, and that ends at the end of the string. The delimiter string is not a list of individual delimiters, but a single delimiter which may be multiple characters. In other words, if your delimiter is ok, After looks for occurrences of those two lowercase letters and returns a value after the first such occurrence that follows the start value.
  • This method is always case-sensitive.

Examples

The following string (note the initial blanks) is the result of the request displayed below it:

  I am the Walrus! Koo Koo Kachoo!

begin %x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') printText {%x:after('!')} end

The following string is the result of the request displayed below it:

  Koo Koo Kachoo!

begin %x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') printText {%x:after('!',start=20)} end

The following request prints each blank-delimited word, one at a time:

begin %x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') repeat while %x:length print %x:before(' ') %x = %x:after(' ') end repeat end

See also