Forum Discussion

PiotrBurchart-d's avatar
PiotrBurchart-d
Community Member
2 months ago

Keep variable changes

Hi, can a variable change be kept in another variable after changing it? For example, we have:
Text variable "a", Text variable "b". Now, variable a will change (newly added text). The action is to assign variable "b" with "a", so variable "b" contains the variable's contents. I clear variable "a" - value empty. Is it possible to keep the text in variable "b" when a changes? When var. "a" changes, "b" also changes the content.

I appreciate your help.

  • For sure, yes. As all triggers act sequentially, use that. Set var b to the value of a. Only then change A.

  • Hi,

    No, it is not working. When the first original variable changes, then 2nd will also change.

    For example, Variable A is connected to the text entry box; we can type "abcd" and press the submit button to assign a text entry to variable A. From now value of variable A is "abcd", 

    Next, I assigned variable B with A when variable A change. Everything is ok.

    The problem started when I assigned variable A to the value "blank", and then variable B is also blank.

    PS: I have to assign A with a blank value.

     

      

  • AndrewHanley's avatar
    AndrewHanley
    Community Member

    Hi Piotr,

    The problem here is that you are using the WHEN VARIABLE CHANGES trigger. That means every single time Var A updates to a new value, Var B automatically will.

    If you remove this WHEN VARIABLE CHANGES then you can control when Var B will take the value of Var A.

    In other words, you can change Var A as many times as you like, and it will only change Var B when you use a trigger to tell it to change.

    Does that help at all?

  • Hi Andrew,

    I used the attached action.

    When count is = 2 I have Respond2, when is = 3 Respond3.

    However, the client requested a Clear button to assign variables AI_Respons and TextEntry with blank, which is why I have a problem.

    Will send a demo tomorrow.

  • AndrewHanley's avatar
    AndrewHanley
    Community Member

    Im not sure I understand Piotr, sorry.

    What you have written above is a little unclear, but sounds like it should work ok.

    The trigger in your screenshot is perfect...

    if Count=1 when that slide is first loaded, then the variable RESPOND1 will be set to whatever value the variable AI_RESPONSE holds at that time.
    That sounds fine.

    And the client request to clear both variables needs just two triggers:

    ADJUST VARIABLE "Respond1" TO VALUE <blank> WHEN USER CLICKS "clear button"
    ADJUST VARIABLE "AI_Response" TO VALUE <blank> WHEN USER CLICKS "clear button"

  • Hi Andrew,

    Is sorted. See attached.

     

    Thanks for engagement.