Variable Update

PennController for IBEX Forums Support Variable Update

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10772
    lh555
    Participant

    Hi Jeremy,

    I am currently working on an experiment and I found that I needed to use a variable element to keep track of how many
    trials the user had completed. I tried debugging and trying out the general behavior of the variable element. To do that,
    I created the following experiment:

    PennController.ResetPrefix(null);
    
    Sequence('test')
    newVar('counter',10).global();
    
    newTrial('test',
        getVar('counter')._element.value == 10 ? [
            newButton('button','True!')
                .print()
                .wait()
            ]:
            [
            newButton('Button', 'False :(')
                .print()
                .wait()
            ]
          ,
        getVar('counter').set(v=>v+1)
    )
    
    newTrial('test',
        getVar('counter')._element.value == 11 ? [
            newButton('button','True!')
                .print()
                .wait()
            ]:
            [
            newButton('Button', 'False :(')
                .print()
                .wait()
            ]
    )
    

    When running this file, the statement getVar(‘counter’)._element.value == 11 evaluates to false. I don’t understand
    why this is happening. I would appreciate it if you could help me out.

    Thanks

    #10774
    lh555
    Participant

    Hello,

    I have resolved the issue by simply using the var.test.is() syntax and a functional expression.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.