Macro Engine - Setdataif with variable

    Macro Engine - Setdataif with variable

    Hi everybody,

    I have a small and easy macro, unfortunately the last command isn't working. Any ideas?
    The basic idea is to enable setdataif over a variable. After the data is written into the cube the variable should be set to false.
    As a result the variable only changes to true and stays true...



    function
    Button3_Click ()


    {


    // Setting global variable on true -> for a palo.setdataif function

    define_variable('setd', 'true');

    return __recalc();

    return __msgbox('Changes saved', 'Saving...');

    // trying to set the variable on false is not working

    define_variable('setd', 'false');

    }



    Thanks for your help,

    Stephan
    Hi,

    I took off the msgbox statement and got the same result...
    After that I tried your hint which isn't working at all. Is there another workaround?
    The main idea should be that the worksheet has some time to setdata and after that disable setdata.

    Button3_Click ()

    {

    define_variable('setd', 'true');
    define_variable('setd', 'false');
    return __recalc();


    }
    sorry that made obviously no sense:


    Button3_Click ()

    {
    // set the trigger cell to true
    define_variable('setd', 'true');

    // launch the recalc (=> launches the setdata)
    return __recalc();

    // reset the trigger cell to false
    define_variable('setd', 'false');

    }

    hope this helps!
    laloune

    Post hoc, non est propter hoc
    laloune's last code snippet again executes something after the "return" statement, which can't work.
    However, I don't think you need to use "return __recalc" method here. Try this:

    Source Code

    1. Button3_Click ()
    2. {
    3. // set the trigger cell to true
    4. define_variable('setd', 'true');
    5. // launch the recalc (=> launches the setdata)
    6. activesheet()->calculate();
    7. // reset the trigger cell to false
    8. define_variable('setd', 'false');
    9. }
    Well, the sheet is calculating and the variable has value false at the end.
    But the setdataif doesn't do its job.
    I think there is not enough time for the setdata. The amount of the cells having a setdata on the worksheet is quite huge (3 columns with 200 cells writing into an attribute).
    Any other ideas?