Keith, 

Think about this

The "variables" in REBOL are a pointer to a value or an index to a series. 

Every action in REBOL is a fuction, which returns a value. You can ignore the value 
returned, or assign it to a variable.

In the case of a series, the values are an index to an item in the series. (1, 2, 17)

Functions like insert do not change where the variable points. If you want to change 
the variable's index or value, you can assign it the value returned by the function.

If you insert a value using one pointer to a series, the other pointer will still 
selects nth item, which may be another member of the series.

If you have a pointer to the 12th member in a series, and insert values after it, it 
will still point to same member. 

If you have a pointer to the 12th member in a series, and insert values before it, it 
will still point to the 12th item, but that will be a different member (since the 
inserts pushed it to the 13th or whatever item).

If you want to insert in a particular place, you can use functions like Find to figure 
out where it is. 

I don't know if you can set a variable to the 12th item on a list and still have it 
point to that particular member regardless of other changes to the series. 

Consider 

>>colors: ["r" "g" "b"]
==["r" "g" "b"]
>>colors2: next colors
=='["g" "b"]
==insert colors "y"
>>["r" "g" "b"]
colors2
==["r" "g" "b"]
head colors2
==["y" "r" "g" "b"]
colors
==["y" "r" "g" "b"]
clear colors2
== []
colors
== ["y"]

Also, in your examples, you've been inserting words into strings. Keep in mind that a 
string is a series of characters, not a series of words.

*********** REPLY SEPARATOR  ***********

On 12/7/1999 at 10:19 PM [EMAIL PROTECTED] wrote:

> The position past the insert is returned, but INSERT does not change the
"cursor" of the original variable.

Awesome, this was the main thing I was trying to understand. Like, if you
do:

>> i: "a"
== "a"
>> insert i "b"
== "a"
>> insert i "c"
== "ba"
>> i
== "cba"

it seems confusing. On the one hand, right after you do an insert, it
returns the series at the point right after what you inserted, but the
variable that points to the series itself is left at the beginning of what
you insert. I finally understand why you can chain inserts together like
this:

>> insert insert i "D" "E"
== "cba"
>> i
== "DEcba"

and have it come out "in order".

The only questions I have left are:

Why does the original series still point to the beginning of what you
inserted? Because of this there is no way to do two inserts separately and
have the second insert appear after the first in the series. I guess this
makes sense. It sort of pushes what you inserted forward in the series and
leaves you where you were.

The other question I have is... because of this behavior, is there any way
to do an insert after another insert and have what you inserted second come
out after what you inserted first? Is there any way to say:

h: "pokey"
insertafter h "the "
insertafter h "hokey "

and have h be "the hokey pokey"

in other words, is there any function that will leave the cursor for the
series after what you inserted?

Or, to put it yet another way, is there any way to sort of "append" at
anywhere but the end of the series and then leave the cursor at the end of
what it appended? This is sort of what I've been trying to accomplish: an
append in the middle of the series.

Thanks to everyone for their help.

Keith



Reply via email to