Author |
Message |
enchanted_bloom
|
Posted: Tue Mar 03, 2009 7:20 pm Post subject: How to make a for loop inside a for loop? |
|
|
As I said, a line is already a for loop,how can I put this loop inside a for loop...I've seperated the two loops,but I don't get how I can put one inside of the other one.
One of the loop is like this
code: | for counter1:1..5
put num," "..
end for |
The other one is like this..
code: | for counter:1..12
put " ":12,counter
end for |
how can I make the first loop repeat by using the second loop format..
Thanks |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Tue Mar 03, 2009 7:27 pm Post subject: RE:How to make a for loop inside a for loop? |
|
|
do you know how a for-loop works? Describe it in words. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
enchanted_bloom
|
Posted: Tue Mar 03, 2009 7:36 pm Post subject: RE:How to make a for loop inside a for loop? |
|
|
The loop will countinue each time adding up the numbers until the number previously declared..
I think..i'm not sure... |
|
|
|
|
|
Tony
|
|
|
|
|
enchanted_bloom
|
Posted: Tue Mar 03, 2009 7:52 pm Post subject: RE:How to make a for loop inside a for loop? |
|
|
It basically is a execution that keeps on repeating according to the number of times it was declared,each time adding one to the time repeated.It will stop until it has reached the last value declared.
IS it? |
|
|
|
|
|
Tony
|
Posted: Tue Mar 03, 2009 7:58 pm Post subject: RE:How to make a for loop inside a for loop? |
|
|
yes. Now, what kind of statements can you put in it's place? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
enchanted_bloom
|
Posted: Tue Mar 03, 2009 8:15 pm Post subject: RE:How to make a for loop inside a for loop? |
|
|
I think you can put anything... |
|
|
|
|
|
Tony
|
Posted: Tue Mar 03, 2009 8:19 pm Post subject: RE:How to make a for loop inside a for loop? |
|
|
well... as the name implies: statements And Declarations.
another for-loop happens to be a statement (as is said in top-right corner of the documentation page) |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Sponsor Sponsor
|
|
|
enchanted_bloom
|
Posted: Tue Mar 03, 2009 8:30 pm Post subject: Re: How to make a for loop inside a for loop? |
|
|
uh.huh..i get that part..but if I do it like this
code: | for counter:1..12
for counter1:1..5
put num," "..
end for
end for |
it doesnt work |
|
|
|
|
|
Tony
|
Posted: Tue Mar 03, 2009 8:32 pm Post subject: RE:How to make a for loop inside a for loop? |
|
|
why not? I get a compile error for that piece of code; what does it say? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
BigBear
|
Posted: Tue Mar 03, 2009 8:32 pm Post subject: RE:How to make a for loop inside a for loop? |
|
|
That will start the first for loop then enter the second and stay in the second untill it is done then restart the first one which will go into the second etc. |
|
|
|
|
|
enchanted_bloom
|
Posted: Tue Mar 03, 2009 8:41 pm Post subject: RE:How to make a for loop inside a for loop? |
|
|
when it comes out it's a bunch of letters crampled together when i wanted them to be in seperate lines.. |
|
|
|
|
|
Tony
|
|
|
|
|
enchanted_bloom
|
Posted: Tue Mar 03, 2009 8:45 pm Post subject: RE:How to make a for loop inside a for loop? |
|
|
oh..it makes the second loop continue on the same line making it look like this
X X X X X
if i didn't do that it will look like this
X
X
X
X
X |
|
|
|
|
|
Tony
|
Posted: Tue Mar 03, 2009 8:56 pm Post subject: RE:How to make a for loop inside a for loop? |
|
|
does this solve your problem? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
|