Computer Science Canada

Making a FOR loop repeat only once

Author:  (-.-)>YoGiBeHR<(-.- [ Mon Nov 13, 2006 7:35 pm ]
Post subject:  Making a FOR loop repeat only once

Hello CompSci

I have a main menu, with options: Start, About and Help
When the user clicks START (start is a procedure for the game) the proggie will load the game procedure, and inside that game procedure another procedure for graphics will be loaded inside...

So , how do I make my for loop play only once please, thank you!

Author:  Clayton [ Mon Nov 13, 2006 7:42 pm ]
Post subject: 

some code would be nice to see here, as I don't know why you even have a loop if you only want the code to run once.

However, if you want the code to run only once (for whatever reason you want a loop to run once...), use a for loop:

Turing:

for Index : 1 .. 1
%code in here
end for


You could also have some sort of boolean flag and run a conditional loop:

Turing:

var flag : boolean := false
loop
    %do code
    %action permits an exit
    flag := true
    exit when flag
end loop


Please post the code so we can give some more help

Author:  Dannyd534 [ Mon Nov 13, 2006 7:43 pm ]
Post subject: 

either send me the code and ill try to figure it out or...i think u do somthing like stop(or exit i forgot) when blah blah blah user clicks play or w/e u wanna do

Author:  Dannyd534 [ Mon Nov 13, 2006 7:54 pm ]
Post subject: 

srry for double post but try here http://www.compsci.ca/v2/viewtopic.php?t=13288


: