Reply To: While loop compatability?

PennController for IBEX Forums Support While loop compatability? Reply To: While loop compatability?

#5297
Jeremy
Keymaster

Hi Cindy,

Yes, you cannot freely inject some javascript inside a PennController trial. There is a Function element, but it’s more for running independent routines than to make PennController elements interact with native javascript code.

Your case is a standard setup in PennController, here is what you can do:

newTrial(
    newText("Left").print("right at 48vw", "middle at 50vh"),
    newText("Right").print("left at 52vw", "middle at 50vh")
    ,
    newSelector("choice")
        .add( getText("Left") , getText("Right") )
        .callback( getTimer("timewindow").stop() )
    ,
    newTimer("timewindow", 5000).start().wait()
    ,
    clear()
    ,
    getSelector("choice").test.selected()
        .success( newText("Thank you").print() )
        .failure( newText("Too slow!").print() )
    ,
    newButton("Finish").print().wait()
)

Jeremy