After (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(One intermediate revision by one other user 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.
<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.


==Syntax==
==Syntax==
{{Template:String:After syntax}}
{{Template:String:After syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%outString</th>
<tr><th nowrap>%outString</th>
<td>A string or longstring variable. if a string is specified it must be long enough to hold the resulting parsed string.  If a string is defined shorter than needed to hold the result, a request canceling error occurs.</td></tr>
<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>A string or longstring variable that holds the string to be parsed.</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>A string or longstring variable that holds the separator character or characters on which parsing occurs.</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: The starting point for parsing. The default value is 1, indicating the beginning of the string. This is a name-optional argument and cannot be 0. If a value larger than the string is specified, the method always returns a null string.</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==
If a starting value is entered, the %outString is the content of the string beginning after the first occurrence of the delimiter string encountered after the specified start point, and ending at the end of the string.
<ul>
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', the method looks for occurrences of those two lower-case letters and returns a value after said occurrence,
<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.
This method is always case-sensitive.
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:
The following request prints the following string (note the initial blanks):
<p><code>&nbsp;&nbsp;I am the Walrus!  Koo Koo Kachoo!</code></p>  
<p><code>&nbsp;&nbsp;I am the Walrus!  Koo Koo Kachoo!</code></p>  
<p class="code">begin
<p class="code">begin
Line 30: Line 37:
</p>
</p>


The following request prints
The following string is the result of the request displayed below it:
<p><code>&nbsp;&nbsp;Koo Koo Kachoo!</code></p>  
<p><code>&nbsp;&nbsp;Koo Koo Kachoo!</code></p>  
<p class="code">begin
<p class="code">begin
Line 38: Line 45:
</p>
</p>


The following prints each blank-delimited word, one at a time.
The following request prints each blank-delimited word, one at a time:
<p class="code">begin
<p class="code">begin
   %x is string len 64 initial('I am the Eggman!  I am the Walrus!  Koo Koo Kachoo!')
   %x is string len 64 initial('I am the Eggman!  I am the Walrus!  Koo Koo Kachoo!')
Line 49: Line 56:


==See also==
==See also==
<ul>
<li><var>[[Before (String function)|Before]]</var></li>
</ul>
{{Template:String:Before footer}}
{{Template:String:Before footer}}
The <var>[[Before (String function)|Before]]</var> string method.

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