RosettaCodeData/Task/Loops-With-multiple-ranges/FutureBasic/loops-with-multiple-ranges....

29 lines
760 B
Plaintext

window 1, @"Loops with Ranges", ( 0, 0, 400, 400 )
begin globals
NSInteger sum = 0
float prod = 1
end globals
local fn process( x as float )
sum += abs(x)
if abs(prod) < (2 ^ 27) and x <> 0 then prod = prod * x
end fn
NSInteger j
NSInteger x = 5, y = -5, z = -2
NSInteger one = 1, three = 3, seven = 7
for j = -three to (3 ^ 3) step three: fn process(j): next j
for j = -seven to seven step x: fn process(j): next j
for j = 555 to 550 - y: fn process(j): next j
for j = 22 to -28 step -three: fn process(j): next j
for j = 1927 to 1939: fn process(j): next j
for j = x to y step z: fn process(j): next j
for j = (11 ^ x) to (11 ^ x) + one: fn process(j): next j
print using " sum = ###,###"; sum
print using "prod =-####,###,###"; prod
HandleEvents