J

A good example. And I was thinking that this "new" way of viewing strings (as a collection of chars) could come in handy when scanning/parsing strings.

By way of a simplistic example, is one wanted to code the "infamous" reverse a string routine, one could do this:

code:

for each $char in "hello world"
$reversed = $char + $reversed
next

Here's the same routine, coded with a UDF:

code:

for each $char in CharArray("hello world")
$reversed = $char + $reversed
next


?"reversed=" $reversed


exit 1


Function CharArray($String)
dim $len,$i
$len = len($String)
$CharArray = ""
if $len = 0
return
endif
dim $array[$len-1]
for $i = 0 to $len-1
$array[$i] = substr("$String",$i+1,1)
next
$CharArray = $array
EndFunction


-Shawn