Repeating a loop x times
Hey all,
I'm using JavaScript for the current exp, and I have defined a variable called "block_size".
When I'm creating a Loop item I want to set the repeats to be "block_size" times.
I've tried the following but with no success:
set repeat "[block_size]"
Am I missing something? Is it supposed to be different while using JS instead of Python?
Thank you!
Comments
Hi @liranpeleg5 ,
This is indeed a bug in OSWeb. I reported the issue:
Until the issue is fixed, just let us know if you need help thinking of a temporary workaround by indicating the exact behavior that you want to implement.
Cheers,
Lotje
Did you like my answer? Feel free to

Thank you for the fast reply!
I would indeed like to get a workaround.
Basically what I need to do is to generate a random
block_sizewith value between 2 and 7.Then, on a later step in the experiment, I need to define a loop to run
block_sizetimes.I don't mind defining
block_sizein a different component if it would work (it's only used in the said Loop item).Any ideas? :)
Hi @liranpeleg5 ,
I think something like the following should work:
loopitemloopitems with similar content (you could uselinked copiesfor copying the content) and call them something like "block_loop_repeat2", "block_loop_repeat3" etc.loopitemsRun-ifstatements (for example in the block-sequence) to determine which block should be run. You could use the following code in theRun-ifboxes:etc.
I uploaded a working example. Hope this helps!
Cheers,
Lotje
Did you like my answer? Feel free to
