
-----------------------------------
person
Sat Mar 12, 2005 7:40 pm

y doesnt this have an output??
-----------------------------------

for x : 0 .. 20
    for decreasing y : 1 .. 20
        locate (x, y)
        put x
    end for
end for


y doesnt this output anything?[/quote]

-----------------------------------
Cervantes
Sat Mar 12, 2005 7:48 pm


-----------------------------------
It skips the second for loop because 1 is less than 20 and because it's decreasing.
In a regular for loop, the first number must be less than the second.  In a decreasing for loop, the first number must be greater than the second.  
You have a decreasing for loop in which the first number is less than the second.  Switch them.

-----------------------------------
mike200015
Sat Mar 12, 2005 7:53 pm


-----------------------------------
you also need to make the 1st for loop start at 1.. since u used locate (x,y) and the x is the for loop that starts at 0, and there is no row 0, so it needs to start at 1

-----------------------------------
ssr
Sat Mar 12, 2005 8:37 pm


-----------------------------------
if u want, use locatexy 
and yes, whenever turing sees a decreasing thats the other way, it will automatically stop/ 8)

-----------------------------------
Token
Sat Mar 12, 2005 8:44 pm


-----------------------------------
so the code would be 

for x : 1 .. 20 
    for decreasing y : 20 .. 1 
        locate (x, y) 
        put x 
    end for 
end for 

but if u wanted the numbers to start at 0, you would have to do this




for x : 1 .. 21
    for decreasing y : 20 .. 1
        locate (x, y)
        put x - 1
    end for
end for

