Howdy, Stranger!

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

Supported by

[solved] setting and getting variables set into Loop items

edited May 2015 in OpenSesame

In eprime it's possible to manage variables ("attributes") inside a loop ("List") in the meaning that at runtime I'm able to retrieve and set those variables even if I am outside the loop.

Could the same be possible using the opensesame's Loop item only and not bulding other arrays?

thanks (again)

Comments

  • edited 11:53AM

    Yep, that's possible. Every variable that is created in an inline_script item, is available in all the other inline_script items, regardless of whether they are placed in a loop or not. If you're creating a variable that you want to be available to items other than inline_scripts, you have to insert exp.set('variablename', variablevalue).

    Cheers,

    Josh

  • edited 11:53AM

    Sorry,

    it seems I was not clear enough with my problem.

    Let's say I have this:

    Loop  (with  var1, var2, myNewVar)
    ----sequence
    -------sketchpad
    -------inlineScript
    -------logger
    outer_inline
    

    inside inLineScript I can write/get vars defined inside the Loop. And this is true each time my InlineScript is run inside the loop for the "current trial"


    I was wondering if outside the Loop I can still get/set those vars defined in that Loop, if they are saved somewhere. Soemthing like

    exp.items['Loop'].myNewVar.value


    thanks!

  • edited 11:53AM

    Hi,

    If this only concerns the current value of a variable in a loop, it is quite straightforward. You can get and set the value just the way as you do from inside a loop.

    Accessing previous values is a bit trickier, but not impossible. The strategy, that I personally think is most sensible, is creating a list or some other container in the loop that mimics the variables you're interested in. This list is then editable for sure. Besides, this has also the adventage that you're still able to see the original values in the log file, which comes in quite handy if you want to check the correctness of your procedure.

    Yes?

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited 11:53AM

    Yes, using an external list is what I am doing now but..

    this seems to me a waste of resources, duplicating and keeping updated all the vars I need.

    Thanks for your help

Sign In or Register to comment.