you've pretty much got the right idea, except you can use $mid(%x, 2) to return %x without its first character (ie. 2nd character onwards). $mid() with its extra parameter and negative index support can often be used in place of longer and more uncomfortable $left / $right combinations. in this case, $right(%x, -1) would have also sufficed (everything except the rightmost character).

careful using loops such as while ($gettok( ... )), $null is not the only thing that stops such loops. they also stop when the number 0 or the word $false is encountered.

if methodology interests you, there is another technique involving the $* identifier:

Code:
//tokenize 32 a string of words here | var %x | scid $cid set -n $eval(%x %x, 0) $!upper($left( $* , 1)) $!+ $!mid( $* , 2) | echo -a %x


to get an idea of what's happening there, see:

Code:
//tokenize 32 a string of words here | var %x | echo -a scid $cid set -n $eval(%x %x, 0) $!upper($left( $* , 1)) $!+ $!mid( $* , 2) 


$* triggers an internal loop whereby the line is initially evaluated, then each of $1, $2, $3, etc. are substituted in for $* and the resulting command performed. since it sets up /scid commands with literal text from $1- inside, this method should only be used if you're sure $1- will not contain pieces of code that should not be evaluated.

also pay attention to the use of /set -n. /set modifies local variables if ones of the same name already exist, and the -n is useful to prevent it from evaluating mathematical expressions, such as in $begin_caps(1 + 1) in your example. i'd always recommend at least using /set -n when dealing with arbitrary pieces of text.




"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde