Edit Values

Options
Eduardo Gamero
Eduardo Gamero Member Posts: 30 Member

Is it possible to make a control remember a value and return automatically?


For example:


If (%CC[3] = 0)


Change values like these


$switch_1 := 1


$knob_1 := 6


$value_edit_1 := 87


And if (%CC[3] = 1)


All values return to 0 to edit again and do the same with (%CC[3] = 2) etc.


But when returning to (%CC[3] = 0)


Return the values as they were then.

Comments

  • Gablux
    Gablux Member Posts: 82 Member
    Options

    It is possible.

    It is a matter of managing storage of data in case you need to retrieve them later.

    I say in case because you said "All values return to 0 to edit again" which is not clear why they would need to go to zero.

    Still think that, as you presented, in the condition %CC[3] = 0 evaluating to true, you would need to retrieve 3 values, one for swtich_1, one for knob_1 and one for value_edit_1. So you need a way to store these 3 values neatly together. And you need 3 more for the condition %CC[3] = 1 and so on.

    So you need 3 (values) times however many conditions you have. Let's say you have 3 conditions.

    To store values together you usually use an array. In this case:

    declare %skv_values [9]

    %skv_values [0] := 1

    %skv_values [1] := 6

    %skv_values [2] := 87

    %skv_values [3] := 0

    %skv_values [4] := 7

    %skv_values [5] := 89

    { ficticious values, for the sake of the example }


    then later you would use, I believe in the controller callback:

    if (%cc[3] = 0)

    $switch_1 := %skv_values [0]

    $knob_1 := %skv_values [1]

    $value_edit_1 := %skv_values [2]

    end if

    if (%cc[3] = 1)

    $switch_1 := %skv_values [3]

    $knob_1 := %skv_values [4]

    $value_edit_1 := %skv_values [5]

    end if


    which of course you would reduce to:

    $i := 0

    while ($i < 3)

    if (%cc[3] = i)

    $switch_1 := %skv_values [3*i + 0]

    $knob_1 := %skv_values [3*i + 1]

    $value_edit_1 := %skv_values [3*i + 2]

    end if

    inc($i)

    end while


    in this version of the code you can manage all possibilities from %CC[3] = 0 to 127 in one neat loop.

  • Eduardo Gamero
    Eduardo Gamero Member Posts: 30 Member
    Options

    Ok... it's very well explained and it seems like it can help me, I'll try it right away, thank you very much.

Back To Top