List creator

By Roy911 on Jan 13, 2007

List Creator by Roy911

This is a rather simple script that creates a list from a set of tokens.
The token-separator is defined by $1.

Paste in aliases

Note: The identifiers $cap and $wordget are nessesary for use.

Usage:

//echo $list(32,a as asd asdf asdfg asdfgh asdfghj)
Would result in: A, as, asd, asdf, asdfg, asdfgh, and asdfghj.

/*
List Creator by Roy911
irc.abxy.org:#Roy911

Usage:

This is a rather simple script that creates a list from a set of tokens.
The token-separator is defined by $1.

//echo $list(32,a as asd asdf asdfg asdfgh asdfghj)
Would result in: A, as, asd, asdf, asdfg, asdfgh, and asdfghj.
*/

alias list {
  ;This alias creates a list
  var %token = $1
  var %len = $numtok($2-,%token)
  var %pos = 1
  var %list = $null
  if (%len == 1) {
    var %list = $2
    var %list = %list $+ .
    goto return
  }
  if (%len == 2) {
    var %list = $wordget(1,%token,$2-) and $wordget(2,%token,$2-) $+ .
    goto return
  }
  while (%len != 0) {
    if (%len == 1) {
      var %list = %list $+ , and $+ $chr(32) $+ $wordget(%pos,%token,$2-) $+ .
    }
    else {
      var %list = %list $+ $chr(44) $+ $chr(32) $+ $wordget(%pos,%token,$2-) $+ ,
    }
    inc %pos 1
    dec %len 1
  }
  var %list = $mid(%list,3,$len(%list))
  ;echo $active %list
  var %list = $cap(%list)
  :return
  ;echo $active %list
  return %list
}
alias WordGet {
  var %word = $1
  var %sep = $2
  var %token = $3-
  var %return = $gettok(%token,%word,%sep)
  return %return
}
alias cap {
  return $upper($mid($1-,1,1)) $+ $lower($mid($1-,2,$len($1-)))
}

Comments

Sign in to comment.
napalm`   -  Sep 16, 2008

This does exactly what you described in your 'Usage'

alias list {
  var %x $instok($regsubex($$2,/ $+ $chr($1) $+ /gi,$+($chr(44),$chr(32))),and,-1,32)
  return $upper($left(%x,1-)) $+ $mid(%x,2,$calc($len(%x) - $iif($regex($right(%x,1),(\.|!|\?|\,)),2,1))) $+ .
}
 Respond  
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.