PennController for IBEX › Forums › Support › Variable Updating › Reply To: Variable Updating
Hi Leo,
It’s hard to tell without seeing your code, but I suspect that the replay makes it so that ultimately, in the sequential flow of commands in your experiment, the command .set( v => Date.now() )
gets executed more than once, and the last time it is executed happens after the last time .set( v => v - Date.now() )
is executed.
Are you trying to record the RT both for the first pass and for the replay? Or only for the replay? In any case, it would probably be cleanest to just use different variables on the two different occasions, e.g. (adapting the code from this topic):
newText("contextText", "Look at the square below").print(), newCanvas("square", 200,200).settings.css("background","red").print(), // Var element for the first RT newVar("RTfirst", 0).settings.log().set(v => Date.now()), newButton("ok", "OK").print().wait().remove(), newText("instructions", "How red is it?").print(), newScale("firstScale", 7).settings.log().print().wait(), getVar("RTfirst").set(v => Date.now() - v), newButton("Replay").print().wait().remove(), // Removing everything still on screen getText("contextText").remove(), getCanvas("square").remove(), getText("instructions").remove(), getScale("firstScale").remove(), // Wait 500ms before reprinting newTimer(500).start().wait(), getText("contextText").print(), // Var element for the second RT newVar("RTsecond", 0).settings.log().set(v => Date.now()), getCanvas("square").print(), getButton("ok").print().wait().remove(), getText("instructions").print(), // Print a new scale newScale("secondScale", 7).settings.log().print().wait(), getVar("RTsecond").set(v => Date.now() - v)
Unfortunately you cannot use getVar
after =>
in the set
command the way you’ve tried, because it actually is in a non-PennController environment (which incidentally also makes it possible to use Date.now()
upon runtime). If you really need to access the value of the Var element there, you need to use getVar("sentenceDisplayTime")._element.value
.
Let me know if you have more questions!
Jeremy