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

The following sections explains each way.

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

With the break-Statement you can control the termination of the loop:

set i to 0

while true
    print(i)

    if i == 100 break endif

    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

Clone this wiki locally