Dinfio Documentation
There are three types of control flow in Dinfio: Conditional if, loop for, and loop while.
if is used to execute different block of statements based on certain conditions.for is used to execute block of statements repeately with a specified number of times.while is used to execute block of statements again and again as long as the condition is true.ifPattern 1:
if condition
' Statements to be executed if condition is true
endif
Example:
score = 90
if score >= 80
writeln("Your grade is A")
endif
' Output: Your grade is A
Pattern 2:
if condition
' Statements to be executed if condition is true
else
' Statements to be executed if condition is false
endif
Example:
a = 45
if a >= 50
writeln("Passed")
else
writeln("Didn't pass")
endif
' Output: Didn't pass
Pattern 3:
if condition_1
' Statements to be executed if condition_1 is true
elseif condition_2
' Statements to be executed if condition_1 is false and condition_2 is true
endif
Pattern 4:
if condition_1
' Statements to be executed if condition_1 is true
elseif condition_2
' Statements to be executed if condition_1 is false and condition_2 is true
else
' Statements to be executed if all conditions are false
endif
Example:
score = 70
if score >= 80
writeln("Grade is A")
elseif score >= 70
writeln("Grade is B")
elseif score >= 60
writeln("Grade is C")
else
writeln("Grade is D")
endif
' Output: Grade is B
forPattern:
for counter, start, end, [step]
' Statements
endfor
counter is control variable for the loop,
start is the initial value of counter,
end is the final value of counter,
and step is the amount by which counter is incremented each time through the loop. step is optional, default value is 1.
Example:
for i, 1, 5
writeln(i)
endfor
Output:
1
2
3
4
5
Another example:
for i, 5, 1, -1
writeln(i)
endfor
Output:
5
4
3
2
1
You can stop the loop immediately using keyword break:
for i, 1, 100
writeln(i)
if i == 4
break
endif
endfor
Output:
1
2
3
4
whilePattern:
while condition
' Statements to be executed again and again as long as condition is true
endwhile
Example:
i = 1
while i < 5
writeln(i)
i += 1
endwhile
Output:
1
2
3
4
Just like loop for, you can stop the loop while immediately using keyword break as well:
i = 1
while i < 50
writeln(i)
if i == 5
break
endif
i += 1
endwhile
Output:
1
2
3
4
5
| ← Operators | Index | Functions and Classes → |
Documentation version: 1.1.03. Updated on: 11 February 2026.
Dinfio is designed and written by Muhammad Faruq Nuruddinsyah. Copyright © 2014-2026. All rights reserved.