PennController for IBEX › Forums › Support › Trouble storing/printing value of selector element to results file
- This topic has 2 replies, 2 voices, and was last updated 5 years ago by CBill.
-
AuthorPosts
-
November 14, 2019 at 11:52 am #4335CBillParticipant
Hi,
I would like to store the value of a Selector element in in a Variable and then have it logged on every row pertaining to each relevant item. I believe this is possible, however, when I try I get the following error: ‘Command ‘toJSON’ unknown on Image element ‘HappyFace’.’
Any idea what might be going on? The code for the relevant items is the following:
PennController.Template(PennController.GetTable( "training.csv" ), variable => PennController("training", newTimer(500) .start() .wait() , newAudio("sentence", variable.AudioFile) , newImage("image", variable.Image) .settings.size(250, 187.5) , newImage("HappyFace", "HappyFace.png") .settings.size(133, 133) , newImage("SadFace", "SadFace.png") .settings.size(133, 133) , newImage("DogFace", "DogFace.png") .settings.size(71, 53) , newCanvas("myCanvas", 450, 450) .settings.add("center at 50%", "middle at 25%", getImage("image")) .settings.add("center at 25%", "middle at 75%", getImage("HappyFace")) .settings.add("center at 75%", "middle at 75%", getImage("SadFace")) .settings.add("center at 50%", "middle at 100%", getImage("DogFace")) .print() , newSelector() .settings.add(getImage("DogFace")) .settings.callback(getAudio("sentence") .play() .settings.log("play") .settings.log("end") .wait("first")) , newVar("Response") , newSelector("SelectedResponse") .settings.add(getImage("HappyFace"), getImage("SadFace")) .settings.log() .settings.once() .wait() .setVar("Response") , newTimer(500) .start() .wait() ) .log("ID" , getVar("ID") ) .log("Type", variable.Type) .log("Condition", variable.Condition) .log("Item", variable.Item) .log("Response", getVar("Response")) .log("CorrectResponse", variable.CorrectResponse) .log("StartDet", variable.StartDet) );
- This topic was modified 5 years ago by CBill. Reason: Typos
November 14, 2019 at 1:46 pm #4337JeremyKeymasterHi Cory,
It’s a known bug of sorts: you are storing the image element itself in the variable, rather than the name of the element, which is presumably what you want to get in your log command. I’ll see if I can fix it in the next release of PennController, because I think what you’re doing makes total sense.
In the meantime, here is what you can do:
newVar("Response") .settings.global() , newSelector("SelectedResponse") .settings.add(getImage("HappyFace"), getImage("SadFace")) .settings.log() .settings.once() .wait() .test.selected(getImage("HappyFace")) .success( getVar("Response").set("HappyFace") ) .failure( getVar("Response").set("SadFace") )
I’m making the Var element global because you are accessing it from outside PennController(), even though it seemed to be working even without the .settings.global() line…
Jeremy
November 15, 2019 at 4:12 am #4338CBillParticipantHi Jeremy,
Oh ok, that makes sense. And I’m ‘glad’ it is a bug as I was going crazy trying to figure out where I had gone wrong with the code.
Thanks alot for that suggested work-around, it should work nicely.
– Cory
-
AuthorPosts
- You must be logged in to reply to this topic.