Mode flatlist.

By sparko on Aug 26, 2009

This uses and manipulates a mode string, and returns a flatlist, for easier parsing, so for example:

+ooo-v+b moo1 moo2 moo3 moo4 !@quakenet.org

would return:

+o moo1 +o moo2 +o moo3 -v moo4 +b !@quakenet.org

alias flatlist { 
  var %mode = $gettok($1-,1,32), %params = $gettok($1-,2-,32),%x = 1,%y = 1,%m = 0, %p = 1,%result,%sign = +
  while ($mid(%mode,%x,1)) { 
    var %d = $ifmatch
    if (%d == -) { var %m = 1 | var %sign = - }
    elseif (%d == +) { var %p = 1 | var %sign = + }
    if ($istok(o v b k l,%d,32)) && (!$istok(+ -,%d,32)) { 
      if (%m == 1) { inc %y | var %result = %result $+(%sign,%d) $gettok($1-,%y,32) }
      elseif (%p == 1) { inc %y | var %result = %result $+(%sign,%d) $gettok($1-,%y,32) }
    }
    inc %x
  }
  !return %result
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.