Howdy, Stranger!

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

Supported by

[solved] setting cycles

edited December 2013 in OpenSesame

hi
I am trying to define cycle number from a variable and not a specific number.
I tried to edit the loop object as

set cycles [length]

but it didn't worked
any suggestions?
thanks
p.s. - I love using opensesame - you are doing a great job!

Comments

  • Hi,

    For the moment, it is not possible to use a variable for setting the number of cycles. You may want to consider the following solution to run a given sequence for a variable number of times:

    1.) Directly append your trial sequence to a block sequence (a block loop is not necessary, because we'll determine the number of cycles ourselves)
    2.) Set the Run-if statement of the trial sequence to 'never'
    3.) Add an inline_script to the beginning of your block sequence

    image

    4.) And put something like the following in its Run phase tab:

    # Loop through a cycle of the desired length:
    for i in range(self.get("n_cycles")):
        exp.items["trial_sequence"].prepare()
        exp.items["trial_sequence"].run()
    

    I uploaded an example experiment here (download, change the extension to .opensesame and open as normally):

    Does that make sense?

    Cheers,

    Lotje

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

  • edited 1:50PM

    works like a charm!
    your solution is very simple and it is now a part of my exp.
    before your replay I managed to do it with "repeat_cycle" - can you see a downside to my solution?
    thank you very much!
    Dror

  • Hi Dror,

    I think your solution is a very good idea! :) I can't see any advantages for one approach above the other.

    Good luck!

    Lotje

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

Sign In or Register to comment.