-
Notifications
You must be signed in to change notification settings - Fork 0
Control flow
Julius Paffrath edited this page Jul 18, 2018
·
7 revisions
In jask you can use different types to control your program:
- if-else conditions
- run-loops (like for or while loops in other languages)
See the following example how to use if-else conditions:
if 1 equals 1
print("equal")
else
print("not equal")
endifIf you don't need the else-block, you still have to specify it:
if 1 equals 1
print("equal")
else
endifYou can use the following statements in your if-else condition:
- equals
- unequals
- greater
- greaterequals
- smaller
- smallerequals
Additionally, you can use the modulo operator:
if myNum mod 2 equals 0
print(myNum:" is even!")
else
print(myNum:" is odd!")
endifIf you want to execute parts of your code multiple times, use a run loop:
run i from 0 to 10 with i plus 1
printLine("i is ":i)
endrunA loop combined with a condition is called a while loop:
while CONDITION
[...]
endrunCONDITION can be everything that works in an if-condition. For example:
store 0 in i
while i smaller 100
print(i)
assign i times 2 to i
endrunIf you want to iterate a list, use the for loop:
for element in list(1:2:3)
printLine(element)
endrun- Home
- Getting started
- Control flow
- Functions
- Passing by value
- List variables in jask
- Dictionary variables in jask
- Structs in jask
- Convert variables
- Internal Functions
- The access operator
- Callbacks in jask
- Modules
- Internal Modules
- The jask standard library jcore
- Using CMD arguments in jask
- Nested function calls
- Functions inside functions!
- Modules inside functions!
- Performance comparison of loops