Howdy, Stranger!

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

Supported by

[open] Set time limit for loop

JvHJvH
edited April 2014 in OpenSesame

Hi,

I would like to set a one minute time limit for a loop, is that possible. If yes, how do I do this?

Thanks!

Comments

  • edited 2:32AM

    Of sorts, yes. A loop cannot be aborted halfway, but you can use a break-if statement (under 'Show advanced options') to prevent a loop from starting a new cycle.

    Let's say that you have a structure like this:

    image

    You can then make use of the fact that most items have a time_[item name] variable that contains the time that the item was last executed. To break the loop after 5 s, you could use a Python-style break-if statement like this:

    =self.has('time_sketchpad') and self.get('time_sketchpad') > self.get('time_start_marker') + 5000
    

    Basically, this means that the loop should be aborted if the timestamp of sketchpad is more than 5000 ms later than the timestamp of start_marker. In addition, we make sure that the variable time_sketchpad actually exists (with self.has()) otherwise we get an error at the first iteration of the loop, when sketchpad has never been executed yet.

    Does that make sense?

    For more information about if statements and variables, see:

    Cheers,
    Sebastiaan

Sign In or Register to comment.