Computer Science Canada [Tutorial] [Blitz] For loops |
Author: | Cervantes [ Thu Feb 19, 2004 8:57 pm ] | ||||||||||
Post subject: | [Tutorial] [Blitz] For loops | ||||||||||
For Loops
what they are For loops are used to execute a code between the 'for' and the 'next' lines. The code is executed a set number of times, decided by the parameters you enter at the 'for' line. For loops also keep track of how many times the code has been repeated in a variable (that doesn't need to be declared beforehand) Syntax the first line
qwerty can be anything you want, as long as it is not a command or already used variable. It is the counter. 1 To 10 sets the number that qwerty begins at, and 10 sets the number that qwerty ends at. This for loops will execute code 10 times. The last line
Simple enough ![]() you can put whatever code you want between there. It's totally up to you! Here's an example of code that counts to 5!!!!!!!!!!!!!!!!!!!!!
You can also count by different intervals, using Step.
"Cervantes! How do I do 'decreasing' like in good ol' turing?!" You said it! How do you do decreasing?!
tricky huh? |
Author: | jonos [ Thu Feb 19, 2004 9:23 pm ] |
Post subject: | |
wow, nice tutorial, really makes me understand the syntax. is there a need for a 'decreasing' word like in turing for a decreasing for loop, or can it just be the same just with a higher first number and lower second number. |
Author: | shorthair [ Thu Feb 19, 2004 9:30 pm ] |
Post subject: | |
You are doing such an awsome job guys , thanks so much for hte support in here ,these tutorials rock , they are alot easier to understand , unlike mine THIS is awsome you have my seal of approval ( if it means anything to you ) ![]() |
Author: | shorthair [ Thu Feb 19, 2004 9:31 pm ] |
Post subject: | |
Psssst , just rename it with " ( Blitz ) " at hte end , to seperate it from dark in case anyone ever does some work with it |
Author: | Cervantes [ Fri Feb 20, 2004 4:48 pm ] | ||||
Post subject: | |||||
Sweet! I have the Shorthair seal of approval! Now all I need is a pic of it in my inventory ![]() Jonos: try the following
It doesn't give you an error, it just doesn't do it. as for why we need decreasing for loops? You wrote that lil program that made a boarder, then I made a better one ![]()
That would have been easier with decreasing for loops. esp the first part. instead of using x1 and y1 and x2 and y2, I could have just used the for variable. |
Author: | jonos [ Fri Feb 20, 2004 4:57 pm ] |
Post subject: | |
that is some nice stuff there!!! i will give up for now, but just wait... |
Author: | jonos [ Wed Feb 25, 2004 5:40 pm ] |
Post subject: | |
hey... i found how to do decreasing, i was looking throught the blitz tutorials and i found this, straight from the help, i didn't right it: You can also step backwards by placing a minus (-) sign after the command with the number of steps backwards you would like to take: For A = 10 To 0 step -2 Print A Next This would print: 10 8 6 4 2 0 |
Author: | shorthair [ Wed Feb 25, 2004 8:26 pm ] |
Post subject: | |
Thats one way to do it , there is a more complex way and it allowy you to add some more cool options , its used when decreasing in hte z axis , but your very right on that decreasing loop , MAKE IT A TUTORIAL |