From WikiChip
Editing mirc/commands/tokenize

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 1: Line 1:
{{mirc title|/tokenize Command}}
+
The '''/tokenize command''' is used to fill the $1 $2 ... $N identifiers with [[tokens]] in a string separated by a [[delimiter]].
The '''/tokenize''' command replaces the existing $0 through $N'th tokens, filling $1 $2 ... $N identifiers with portions of a string, divided into tokens based on the location of the <C> delimiters. It also fills $0 with an integer containing the number of tokens filled from the string.
 
  
 
== Synopsis ==
 
== Synopsis ==
 
  /tokenize <C> <text>
 
  /tokenize <C> <text>
 +
 
== Switches ==
 
== Switches ==
 
None
 
None
  
 
== Parameters ==
 
== Parameters ==
* '''<C>''' - The code point ($asc() value) 1-65535 of the character used as the delimiter (If the codepoint is not present within <text> the entire string is filled into $1)
+
* '''<C>''' - The code point ($asc() value) of the character used as the delimiter
 
* '''<text>''' - The string of <C> delimited tokens which will fill the $N identifiers
 
* '''<text>''' - The string of <C> delimited tokens which will fill the $N identifiers
 +
 
== Example ==
 
== Example ==
 
Typing the following into the editbox returns a result:
 
Typing the following into the editbox returns a result:
Line 22: Line 23:
 
<pre>Result of $1: This is</pre>
 
<pre>Result of $1: This is</pre>
  
<source lang="mIRC">
+
== Compatibility ==
Tokenizing follows the same rules as used by $gettok() and the other $*tok identifiers, where it strips leading, trailing, and consecutive delimiters. Consecutive delimiters does not result in a $null token:
+
Added:  
//tokenize 64 @1@@2@@3@@ | echo -a (1) $1 (2) $2 (3) $3 (4) $4
 
returns: (1) 1 (2) 2 (3) 3 (4)
 
This means that tokenizing by other than space 32 can result in tokens having leading or trailing spaces causing tokens to be treated differently:
 
//tokenize 46 1 .2 .3 | echo -a $len($2) / $asc($mid($2,2)) | echo -a $!2 value is $2 which is $iif($2 isnum,numeric, non-numeric)
 
returns: $2 value is 2 which is non-numeric
 
  
'''Note:''' because this is a /command not an $identifier, leading trailing or consecutive spaces are removed from <text> before (but not after) the tokenizing. But if tokenizing by 32, the leading and trailing spaces are also removed from the created $1 ... $N'th tokens.
 
 
Using /tokenize destroys the existing $1- tokens, so if you still need those, you should save them to a variable or use tokenize within another alias. If you use tokenize within an alias called from another alias, using tokenize does not affect the $1- values seen by the original alias.
 
//tokenize 32 the quick brown fox jumps over the lazy dog | while ($1) { echo -a $1- | tokenize 32 $2- }
 
 
//tokenize 32 1.0 2.0 3.0 4.0 | echo -a changes from: $1- | if (. isin $2) tokenize 32 $1 $int($2) $3- | echo -a changes to: $1-
 
returns: 1.0 2 3.0 4.0
 
</source>
 
== Compatibility ==
 
{{mIRC compatibility|5.6}}
 
 
== See also ==
 
== See also ==
 +
* [[List of commands - mIRC|List of commands]]
 +
* [[List of identifiers - mIRC|List of identifiers]]
 
* {{mIRC|$1-}}
 
* {{mIRC|$1-}}
 +
* {{mIRC|$0}}
 
* {{mIRC|$gettok}}
 
* {{mIRC|$gettok}}
 +
{{mIRC command list}}
 +
 +
[[Category:MIRC commands]]

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)