Problem with run_if statement
Dear all,
I need your help because I recently updated to Opensesame 4 with OSWeb 2.
I simply need to create dynamically a variable in javascript after a keyboard response, so I did:
var choice = response (after a keboard_response object)
After that I want to use choice variable in a run_if sequence to show 2 different sub-sequence based on choice value, like this:
sequence1 -- run_if [choice] == 1 (in GUI)
sequence2 -- run_if [choice] == 2
I do not know why, but the script exit without entering in sequence1 or sequence2.
I tried also to put choice instead of [choice], but unfortunately it did not work either.
I inspected choice variable and it contains the right value.
Can you help me to solve this misunderstanding? I think I messed up in the recent variable scope different definition. :)
Thank you all!
Comments
Hi @lucaseme ,
Based on your description it sounds like you're doing everything correctly. Can you attach the experiment, or a simplified version of the experiment that illustrates the issue?
— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @sebastiaan ,
thank you for your reply :)
I am sending you in attach a simplified version of the experiment.
I feel a little frustrated because I think it is a trifle, but I am doing something wrong.
Hi @lucaseme ,
Ah, I see. This seems to be a backwards incompatibility where the conversion from string to number isn't done automatically. (I'm not sure why this behavior has changed to be honest.) You can work around this by using the new-style if-expressions, as opposed to the old-style [square bracket] notation. Like so:
See also:
— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thank you very much @sebastiaan !
The workaround is working.
I have a correlated problem when I use the "break_if" statement: I cannot use complex conditions with "and" / "or". They simply do not verify the exit condition. Maybe it is another problem with string conversion.
It is not very important because I can fix it with an inline script where I reduce complex conditions to one simpler condition, but I want to let you know this misbehavior.
All the best,
Luca