Reply To: And logic in conditional statement

PennController for IBEX Forums Support And logic in conditional statement Reply To: And logic in conditional statement

#4879
Jeremy
Keymaster

Hi,
There are two undocumented commands and and or that let you do just what you want, e.g:

newTrial(
        newScale("score", 10).print()
        ,
        newSelector("text")
        ,
        newText("hello").print().selector("text")
        ,
        newText("world").print().selector("text")
        ,
        newButton("validate")
            .print()
            .wait( 
                getScale("score").test.selected(5).and(
                    getSelector("text").test.selected( getText("hello") ) 
                )  
            )
)

Be careful with selector.test.selected though, as it will crash if run when no element is selected. I’ll fix this bug in the next release, for the moment you should probably use a wait command on the selector before testing it.