Computer Science Canada

command to go to beginning of loop

Author:  n00b.skillz [ Sat Jan 13, 2007 8:28 pm ]
Post subject:  command to go to beginning of loop

in my proc i am making a statment such as
code:

loop
   Font.Draw (question, 1, maxy - 50, fontID2, 7)
    Font.Draw ("a)     " + a, 1, maxy - 100, fontID2, 7)
    Font.Draw ("b)     " + b, 1, maxy - 140, fontID2, 7)
    Font.Draw ("c)     " + c, 1, maxy - 180, fontID2, 7)
    Font.Draw ("d)     " + d, 1, maxy - 220, fontID2, 7)
    get guess
    if guess="a" or "b" or "c" or "d" then
    cls
    if guess = "a" and right = "a" then
        Font.Draw ("Right! Good Job!", 75, 570, fontID, green)
        count := count + 1
    elsif guess = "b" and right = "b" then
        Font.Draw ("Right! Good Job!", 75, 570, fontID, green)
        count := count + 1
    elsif guess = "c" and right = "c" then
        Font.Draw ("Right! Good Job!", 75, 570, fontID, green)
        count := count + 1
    elsif guess = "d" and right = "d" then
        Font.Draw ("Right! Good Job!", 75, maxy - 30, fontID, green)
        count := count + 1
    else
        Font.Draw ("Wrong", 75, 570, fontID, red)
        if right = "a" then
            Font.Draw ("It was a) " + a + ".", 1, maxy - 150, fontID2, 7)
        elsif right = "b" then
            Font.Draw ("It was b) " + b + ".", 1, maxy - 150, fontID2, 7)
        elsif right = "c" then
            Font.Draw ("It was c) " + c + ".", 1, maxy - 150, fontID2, 7)
        elsif right = "d" then
            Font.Draw ("It was d) " + d + ".", 1, maxy - 150, fontID2, 7)
            else  %%%% ??????Beginning of the loop again??
            end if


Cervantes has added code tags.

Author:  CodeMonkey2000 [ Sat Jan 13, 2007 8:52 pm ]
Post subject:  Re: command to go to beginning of loop

I think what you want is to make sure that the user inputs a valid answer. for that i would put it in another loop and wont allow the loop to exit until the user inputs a valid answer. Sort of like:
code:
loop
    if answer = a or b or c then
          exit the loop
    else
        put invalid
        answer
    end if
end loop

Author:  ericfourfour [ Sat Jan 13, 2007 9:07 pm ]
Post subject:  RE:command to go to beginning of loop

The only command to go to the next iteration of a loop, in Turing, is end loop.

Author:  wtd [ Sat Jan 13, 2007 10:56 pm ]
Post subject:  RE:command to go to beginning of loop

"end loop" is best not thought of as a "command". It is a keyword which delimits the end of a loop.

Author:  n00b.skillz [ Mon Jan 15, 2007 6:06 pm ]
Post subject:  Re: command to go to beginning of loop

okay thanks all it is greatly appreciated Cool Very Happy


: