Difference between revisions of "RealTokenize MEL"
From scripting
(Created page with "''Just a note, the MEL tokenize will split up a string, but it will '''not''' remember empty strings. Empty strings are ignored. My "RealTokenize" subroutine will split any...") |
(No difference)
|
Latest revision as of 19:51, 24 April 2017
Just a note, the MEL tokenize will split up a string, but it will not remember empty strings. Empty strings are ignored. My "RealTokenize" subroutine will split any string with a one-character delimiter and remember empty strings.
global proc string[] RealTokenize(string $CurStr, string $Delim) { //Author: Nick Pisca 2010 0001d //string $CurStr = "d,s,d,s,,,,e"; string $Delim = ","; //RealTokenize "d,s,d,,,e,e" ","; string $PartString; string $TempArr[]; int $t = 0; for ($x=1;$x<size($CurStr)+1;$x++) { string $CurLetter = `substring $CurStr $x $x`; if ($CurLetter == $Delim) { $TempArr[$t] = $PartString; $t++; $PartString = ""; } else { $PartString = $PartString + $CurLetter; } } $TempArr[$t] = $PartString; return $TempArr; }
More information on strings and arrays, read pages 28-37 in YSYT.