|
|
| Forums -> Q & A -> Help! Why is this an endless loop? |
JonCraig
|
Help! Why is this an endless loop? |
Posted Dec 12 2009 CLS
DIM PickMap AS STRING
INPUT "Pick the map you are about to play on: ", PickMap
Start! = TIMER
SELECT CASE PickMap
CASE IS = "Narrows"
DO UNTIL TIMER < Start! + 900
DO WHILE TIMER < Start! + 180
PRINT "Rockets spawn."
LOOP
LOOP
CASE IS = "Pit"
DO UNTIL TIMER < Start! + 900
DO WHILE TIMER < Start! + 150
PRINT "Sniper spawns."
LOOP
LOOP
CASE IS = "Construct"
DO UNTIL TIMER < Start! + 900
DO WHILE TIMER < Start! + 120
PRINT "Mauler Spawns"
LOOP
LOOP
CASE ELSE
PRINT "Invalid map. Must either be Construct, Pit, or Narrows."
END SELECT
END |
Clippy
|
It is NOT endless! The loops never start! |
Posted Dec 13 2009 Because of your TIMER loops
DO UNTIL TIMER < Start! + 900 ' never loops!
DO WHILE TIMER < Start! + 180 ' 3 minutes
PRINT "Rockets spawn." ' scroll screen?
LOOP
LOOP
TOSS the outer loops! They do nothing anyhow. Your inside WORKING loops need a fresh start! value since the previous loop.
You don't need to create 3 loops. Use a GOSUB or SUB routine.
Timeloop: ' GOSUB timeloop calls it
start! = TIMER
DO WHILE TIMER < Start! + 180 ' 3 minutes?
LOOP
Why are you waiting 3 minutes and printing things over and over?
|
JonCraig
|
I'm new at this.. |
Posted Dec 13 2009 .. but I'm trying to create a loop that will display a message every 2 minutes then ends at 15 minutes. |
Clippy
|
There is a BIG differance between UNTIL and WHILE |
Posted Dec 14 2009 DO UNTIL TIMER < Start! + 900
Never loops until TIMER is > start! + 900
That means 900 seconds must pass before anything will happen!
Including the other loops. If you want a timeout timer then place the loop around the entire procedure using WHILE instead.
|
jazzy17
|
UEFA CHAMPIONS LEAGUE |
Posted Apr 03 2010 Hi i wrote a program for The UCL, and was wondering on some ideas, firstly the way I selected the groups was using for and next and goto, is there an easier, quicker way of selecting groups?
Also there is a feature I would like to include which is Head to Head, which is simply if teams are level on points, there individual record is used, I can't quite figure this out? |