Appending to a series of strings
[1/2] from: seth:chromick:earthlink at: 18-Nov-2003 7:45
>> a: [1 2 3 4 5]
== [1 2 3 4 5]
>> b: [""]
== [""]
>> x: index? a
== 1
>> append b/:x "hi"
== "hi"
>> x: index? find a 4
== 4
>> append b/:x "hi"
** Script Error: append expected series argument of type: series port
** Near: append b/:x "hi"
In theory, shouldn't append do it's thing on b/4 ... What's with the
error? :\
[2/2] from: SunandaDH::aol::com at: 18-Nov-2003 8:10
Seth:
> In theory, shouldn't append do it's thing on b/4 ... What's with the
> error? :\
b is a block containing one thing: a string
The first append appends to the one and only thing in b -- it's the same as:
b: [""]
append b/1 "hi"
As there is only one thing in b, b/2, b/3 etc can't be resolved.
length? b
== 1
b/2
==none
The one thing in b has a length of 2 and you can append to that:
append b/1 "low"
== "hilow" ;; item b/1 has been extended
probe b
== ["hilow"] ;; but b still contains only one thing
So, if you really want more than one string, you need to set b up with more
than one to start with -- try smething like:
a: [1 2 3 4 5]
b: copy loop 4 [append [] copy ""]
x: index? a
append b/:x "hi"
x: index? find a 4
append b/:x "hi"
probe b
== ["hi" "" "" "hi"] ;; b/1 and b/4 both extended
Sunanda.