Home   Archive   Permalink



Variable changing when it shouldn't

Here is a simple script output. I can't understand why var1 is changing. I don't want it to change. I want to copy var1 into var2 and work with var2 only.
    
var1: ["my" "name"]
== ["my" "name"]
>>
>> f5: "tony"
== "tony"
>>
>> var2: var1
== ["my" "name"]
>>
>> replace var2 "name" f5
== ["my" "tony"]
>>
>> probe var2
["my" "tony"]
== ["my" "tony"]
>>
>> probe var1
["my" "tony"]
== ["my" "tony"]
    
Why has var1 changed, it should be "my" "name" shouldn't it??

posted by:   tony     20-Jan-2012/16:04:59-8:00



You did
    
var2: var1
    
which means var1 and var2 are two references to the same block. If you want an extra block, use COPY in that assignment.

posted by:   Kaj     20-Jan-2012/20:16:55-8:00



Nice, thanks a lot Kaj!

posted by:   tony     20-Jan-2012/21:58:29-8:00