mIRC Homepage
Posted By: BNX String splitting - 29/06/05 03:14 AM
How would I take a character string, or a variable and split each character up into its own variable?
Example

from:
%var = CAT

to:
%var.1 = C
%var.2 = A
%var.3 = T

you guys are too much help grin
Posted By: Collective Re: String splitting - 29/06/05 03:17 AM
Code:
  unset %split.*
  var %i = 1
  while ( %i <= $len($1-) ) {
    set $+(%,split.,%i) $mid($1-,%i,1)
    inc %i
  }

If $1- was "a b c def" you would get:
%split.1 a
%split.2
%split.3 b
%split.4
%split.5 c
%split.6
%split.7 d
%split.8 e
%split.9 f
Posted By: BNX Re: String splitting - 29/06/05 03:34 AM
thanks grin
© mIRC Discussion Forums