Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Problems with variables

edited March 2021 in OpenSesame

Hello,

Could you please help me understand why these errors occur in the attached draft program :

1) The [nbr_exacts] variable contains 0 when the program comes to the end at "Score" although it is incremented correctly during the loop.

2) The program is stuck because the [correct_Rep] variable "does not exist" although it is visible in the list of variables.

Thank you in advance,

Gérard

Comments

  • Hi @gerhono ,


    Thanks for uploading your experiment. That helps a lot! :)


    The program is stuck because the [correct_Rep] variable "does not exist" although it is visible in the list of variables


    The correct spelling (and the spelling that you used in the excel file) is "correct_response". If you change the reference to the variable in the sketchpad accordingly, it should work.


    The [nbr_exacts] variable contains 0 when the program comes to the end at "Score" although it is incremented correctly during the loop


    This is because you used a normal sketchpad item for showing the (updated) variable. Sketchpads are prepared in the Prepare phase of OpenSesame (i.e., when the value of the variable "nbr_exacts" was still zero). Instead, you could use a feedback item for showing the final score. In contrast to a normal sketchpad, the content of a feedback item is generated only in OpenSesame's Run phase. For more information, see here:

    Hope this helps!


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Hi Lotje,

    Thank you very much for your fast reply. The program works, thanks to your advise.

    I understand that when an error message in OS says that "a variable does not exist" (although it is visible in the list of variables), it actually means "that variable is undefined". OK ...

    But what still worries me is the fact that I have used a standard sketchpad in place of a feedback sketchpad, with the same design, in dozens of previous programs and that they are still working, even in this latest version of OS.

    Why are they still working ? A wonderful backward compatibility ?

    May I keep those programs as they are (-> it would take a lot of time to change them) or am I at risk to crash with a future update (-> shame on me) ?

    Cheers,

    Gérard

  • Hi @gerhono ,


    But what still worries me is the fact that I have used a standard sketchpad in place of a feedback sketchpad, with the same design, in dozens of previous programs and that they are still working, even in this latest version of OS.


    But I guess you were not displaying variables that were defined on the fly, right? You can perfectly use sketchpad items to display variables that are defined in a loop item or in the Prepare tab of an inline_script item.


    For response variables (like 'correct', 'response', or 'response_time') you should indeed use a feedback item. (And this has always been the case.) If you do show response variables with a sketchpad item, the displayed values will always be "one trial behind", as in the attached example (where I had to give the response variable a default value to avoid the program from crashing with the "variable does not exist" message - which is correct terminology, because while preparing the content of the very first trial, the variable indeed does not exist yet).



    For your previous experiments: If OpenSesame did not complain that the variable you tried to display does not exist, you don't need to worry. If you did get this error message, and you solved it by giving the variable a starting value at the beginning of your experiment, it might indeed be a good idea to upload one of the experiments here so that we can have a look at it.


    Let me know what we can do for you! :)


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited March 2021

    Hi Lotje,

    It all fits together now !

    Thank you again for your support.

    Cheers,

    Gérard

  • Tant mieux, @gerhono ! :)

    Did you like my answer? Feel free to Buy Me A Coffee :)

Sign In or Register to comment.