Object variable issue

  • I
    Not sure if I use the right words for what things are.
    I have an object constructed that way:
    myvar[i].h
    myvar[i].v
    myvar[i].fov

    Then I want to save a temporary version of all myvar to be able to recall it later.

    To save in temp:
    set (myvarTEMP, get(myvar));

    then myvar is modified but at some point I want to recall to original myvar so I do:
    set (myvar, get(myvarTEMP));

    The saving works.
    The recall doesn't. In fact it looks like myvarTEMP is in fact a reference to myvar so all the modifications done to myvar were updated for myvarTEMP (bad way to say it as it is a reference I suppose). So when I call back the old values they were actually the mod ones.
    I need the temp not to be a reference but a completely independent variable/object.

    I tried search and find ways around this.
    It feels like some basic thing I don't understand.

    Thanks for help anyone.

  • Hi

    I check your problem by this small actions:

    Code
    <action name="checkVartemp" autorun="preinit">    
    set(myvar, 00001);    
    trace('1: ',get(myvar));    
    set(myvarTEMP, get(myvar));    
    trace('2: ',get(myvar),' temp: ',get(myvarTEMP));    
    set(myvar, 00002);    
    trace('3: ',get(myvar));    
    set(myvar, get(myvarTEMP));    
    trace('4: ',get(myvar));  
    </action>


    and I have this data:

    Code
    INFO: 1: 00001  
    INFO: 2: 00001 temp: 00001  
    INFO: 3: 00002  
    INFO: 4: 00001


    It works...

    Best regards
    Piotr

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!