Skip to content
Julius Paffrath edited this page Jul 2, 2026 · 3 revisions

Introduction

jask provides three different ways to repeat code:

  • while
  • for in
  • repeat times

while

A while-loop will repeat the code as long as a condition is true:

set i to 0

while i < 5
    print(i)
    set i to i + 1
endwhile

for in

Use for in if you need to iterate over a set of data stored in a list:

set myList to list(1, 2, 3)

for element in myList
    print(element)
endfor

repeat times

With repeat times one can repeat a statement a predefined number of times (as the name suggests):

repeat task() 5 times

continue and break

Loops can be controlled via continue and break. Continue will skip the rest of the current iteration while break stops the whole loop execution:

set i to 0

while true
    if i == 50 continue endif ; skips the rest of the iteration
    
    print(i)

    if i == 100 break endif ; skips the entire loop

    set i to i + 1
endwhile

Clone this wiki locally