$Initcaps

By Urza on Sep 30, 2005

Just a little alias to capitalise the first letter of each word/token



Usage: $Initcaps(C,TEXT)[.Space]

Eg: $Initcaps(44,one,two,three) returns One,Two,Three



If the .Space property is specified the seperater token is replaced by a space

Eg: $initcaps(124,one|two|three) returns One Two Three



Also Completely unrelated to the snippet i just noticed that 'evolve' is spelt wrong at the top of this page

"This allows people to improve, adapt and evolove your code into something stronger and better"

Alias Initcaps {
  if ($prop == Space) var %TokenChar = 32, %Token = $chr(32)
  else var %TokenChar = $1, %Token = $chr($1)

  if (%TokenChar != 44) tokenize %TokenChar $2-
  var %x = $iif(%TokenChar == 44,2,1)

  while (%x <= $0) {
    var %ctok = $ [ $+ [ %x ] ]
    if (%initcap) var %initcap = $+(%InitCap,%Token,$upper($left(%ctok,1)),$right(%ctok,-1))
    else var %initcap = $+($upper($left(%ctok,1)),$right(%ctok,-1))
    inc %x
  } 
  return %InitCap
}

Comments

Sign in to comment.
tank59   -  Oct 01, 2005

Is the .space property even necessary?
//echo -a $initcaps(32,one two three) returns One Two Three

 Respond  
Vortex   -  Oct 01, 2005

Same here, it doesn\'t work.

 Respond  
Raid   -  Oct 01, 2005

This does not work for me.

 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.