Howdy, Stranger!

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

Supported by

[solved] Calling and logging of variables by identical items within different loops

edited July 2013 in OpenSesame

Hello together, I´m not sure if I understand the way OpenSesame calls (A) and logs (B) variables when using identical items within different loops.

(A)
INLINESCRIPT-Item: represents (together with a logger-Item) my TrialSequence; by using 'exp.get('numberOfSquares') I call a parameter that I typed in for each cycle/trial (of that block) in the table within my LOOP-Item.
This INLINESCRIPT is appended to two loops that contain the identical variables ('numberOfSquares' and others), but different values. So the two loops represent different blocks with different values for the same parameters, and both loops contain the identical InlineScript.
When my InlineScript is called by my second loop, can I be sure that the 'exp.get'-Command also accesses the values of the variable 'numberOfSquares' from the second loop - its parent item - and not from the first loop? What´s the difference to the 'self.get'-Command?

(B)
My experiment works runs without error, but I´m in doubt because the following observation - my second (probably related) problem:
My trialsequence consists not only of the above mentioned InlinceScript but also of a logger-Item. So I use the identical InlineScript and logger-Item within two different loops.
When I click on the logger-Item within my second loop I can only select to log the 'numberOfSquares'-Variable in the list that belongs to the first loop (so called source item).
I mean on the one hand it´s obvious that my selection within the one loop will be my selection within the other loop, because the logger-Item is identical. BUT: Why is only shown that version of the 'numberOfSquares'-Variable which corresponds to the table of the first loop, but not that version with my second loop as its parent item?

(IN SHORT)
I would like to keep my trialsequence (InlineScript + logger-Item) as a re-useable object which I can append to different loops (with the same variables, but different values), taking the values from the respective parent item...

Comments

  • edited June 2013

    Hi,

    Welcome to the forum!

    I'm assuming that your experimental overview looks something like this:

    image

    is that right?

    What´s the difference (between the exp.get() and ) the 'self.get'-Command?

    Variables can exist on two levels: in an item (local) or in the experiment (global). The function exp.get() only looks for the desired variable at the highest (global, experimental, level), whereas self.get() looks first at the item level and then at the experiment level. In most situations this boils down to the same thing (like in your experiment, since a loop item, where you declared your variable, saves variables at the experimental level). Still, I would advise you to always use self.get(). For more information, please see:

    When my InlineScript is called by my second loop, can I be sure that the 'exp.get'-Command also accesses the values of the variable 'numberOfSquares' from the second loop - its parent item - and not from the first loop?

    As said above, I would advise you to use self.get(), but yes, you can be sure about that! For more information about the order in which items in OpenSesame are run, see this article:

    Why is only shown that version of the 'numberOfSquares'-Variable which corresponds to the table of the first loop, but not that version with my second loop as its parent item?

    You're right, the 'source item(s)' column is not always complete. Thanks for pointing this out! We marked it as an issue.
    Yet, the important point is that under the hood everything works as desired: A variable, once defined, is logged appropriately.

    Three easy ways to verify things like this yourself while programming your experiment:

    1.) Use print statements in your inline_script item (which will appear in the debug window):

    print 'self.get', self.get('numberOfSquares')
    

    2.) Temporarily append a feedback item to your trial sequence, where you use the square-bracket method to display the trial variables:

    image

    Finally, with regard to question B, you can verify in your output file whether everything went fine:

    image

    I hope this helps!
    Best wishes,

    Lotje

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

  • edited July 2013

    Hey Lotje,

    thank you for your extensive reply to my questions! I find out that my experiments works well, but now when I read your post I more convinced ;-)
    That issue with not showing the correct source item in the logging list confused me - thanks that it will be considered.

  • edited 8:15AM

    Good to hear that your experiment works! :)
    Let us know if you have any more questions!

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

Sign In or Register to comment.