;Loops in ATALAN
;
;This program demonstrates miscelanenous methods of defining loop ranges.

sum:0..255
type range:5..10
j:0..255

;Loop with own variable

sum = 0
for i : 5..10 sum = sum + i

sum2 = 5 + 6 + 7 + 8 + 9 + 10

"Range [sum]"  ;45

;Loop over type

sum = 0
for i:range sum = sum + i

"Type [sum]"

;Loop over range of some variable

sum = 0
for i:range sum = sum + i

"Var [sum]"

;Loop over existing variable

r:range
sum = 0
for r sum = sum + r

"Global var [sum]"

;Loop over computed range

in out s:0..100 = 5

sum = 0
for i:s..s+5 sum = sum + i

"Variable range [sum]"

;Loop with range defined by function
;
;If a function returns multiple values and the first two are of integer type,
;it may be used to define loop range.

double_range:proc s:byte >a:byte >b:byte = 
	a = s
	b = s * 2
	
sum = 0
for i:double_range(5) sum = sum + i

"Function range [sum]"

"Loop 0..255 ",

steps:card
steps = 0
for i:0..255 inc steps

"[steps]"
   