Sie sind nicht angemeldet.

1

Freitag, 1. November 2013, 19:35

Passing variable values within the same plugin? is it possible? I'm having problems...

Hello,

I suppose the title is not really clear, but I do not know how to title my problem...

So here is the thing...


I have a plugin which contains more than one field:

Quellcode

1
2
3
4
<plugin name="var"
A="text1"
B="text2"
>


If I do


Quellcode

1
2
3
trace(get(plugin[var].A),'   ',get(plugin[var].B));
set(plugin[var].A,'text3');
trace(get(plugin[var].A),'   ',get(plugin[var].B));


then I get an output like

Quellcode

1
2
text1 text2
text3 text2


So, everything is fine!

Now if I want to get the value of var.A into var.B, then I do

Quellcode

1
2
3
trace(get(plugin[var].A),'   ',get(plugin[var].B));
set(plugin[var].B,get(plugin[var].A));
trace(get(plugin[var].A),'  ',get(plugin[var].B));


with the output like

Quellcode

1
2
text1 text2
text1   text1


If I however try to do the following thing

Quellcode

1
2
3
4
trace(get(plugin[var].A),'   ',get(plugin[var].B));
set(plugin[var].B,get(plugin[var].A));
set(plugin[var].A,text4);
trace(get(plugin[var].A),'  ',get(plugin[var].A));


I get as an output

Quellcode

1
2
text1 text2
text4   text4


when what I would expect is

Quellcode

1
2
text1 text2
text4   text1


So, somehow plugin[var].B ist also affected by the set(plugin[var].A,text4) line due to the comand set(plugin[var].B,get(plugin[var].A)); before, although it is not even 'touching' that variable.

How can this be?????
What am I doing wrong??

Cheers

Beiträge: 770

Wohnort: Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

2

Freitag, 1. November 2013, 22:46

I suppose there's a typo in the last line of your latter example:

Quellcode

1
2
3
4
trace(get(plugin[var].A),'   ',get(plugin[var].B));
set(plugin[var].B,get(plugin[var].A));
set(plugin[var].A,text4);
trace(get(plugin[var].A),'  ',get(plugin[var].A));


you meant this, I suppose:

Quellcode

1
2
3
4
trace(get(plugin[var].A),'   ',get(plugin[var].B));
set(plugin[var].B,get(plugin[var].A));
set(plugin[var].A,text4);
trace(get(plugin[var].A),'  ',get(plugin[var].B));


So you were tracing plugin A two times.
Regards,

Alexey