Howdy, Stranger!

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

Supported by

[open] Timed loops

edited April 2013 in OpenSesame


My training group is supposed to do an exercise loop for fourteen minutes, and finish the loop they're on when the times runs out after which the excercise ends. I'm wondering if there is a built in feature to set a loop to run for a set amount of time or if I have to do it with inline scripts, I didn't find anything in the documentation concerning it.



  • edited 5:06PM

    Hi Benjamin,

    The easiest way to accomplish this is by using the 'Break if' statement, which is under 'Show advanced options' in the loop item. For example, the following 'Break if' statement aborts the loop 10 seconds after start time (which you need to set, see below):

    =self.time() - self.get('start_time') > 10000

    This is a Python-style conditional statement, as described here:

    Of course, to make this work, you also need to set the variable start_time. You can do this with a simple inline_script, which you can insert (typically) just before the block_loop:

    exp.set('start_time', self.time())

    Hope this helps!


  • edited 5:06PM

    Hi Sebastiaan,

    'Break if' statement could abort the loop 10 seconds after start time, as in your example. In this case, the timing to abort the loop is before going into the next loop. In my case, I want to abort the loop after a certain period of time, even if it is running the current loop. Is it possible to do so? How can I do to force-quit the sequences after a certain period of time?

    Thanks in advance.

  • edited 5:06PM

    Hi Koba,

    How can I do to force-quit the sequences after a certain period of time?

    This is not really possible. What you can do to accomplish this to some extent is use Run if statements for all items in the sequence, so that these items are skipped when the time period has expired. Something like: =self.time() - self.get('start_time') <= 10000.

    However, this would not halt execution while an item is running (for example while a keyboard_response item is waiting for a response). To accomplish this, you would really need to write an inline script that continuously checks whether the time period has expired, and halts when this happens. Does that make sense?


  • edited 5:06PM

    Thanks, this was exactly what I was looking for.

  • edited April 2013

    Thank you for your quick response.
    I can see your point. Indeed this doesn't sit well with me, but it looks difficult for me to write an incline script that continuously checks the time...

    And, Thank you very much for Runtime for Android. Looking forward to activating the synth and sampler sampler item.

    Kind regards,

Sign In or Register to comment.