Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Repeat the loop
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ashan




PostPosted: Thu Feb 19, 2004 7:07 pm   Post subject: Repeat the loop

Hi,

I'm a beginner in programming. Do any of you know how to repeat a loop (afterr you exit it) without cutting and pasting the whole loop command again?, is that the only way to do it?
pls help me!!

Thanks & regds

Ashan
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Thu Feb 19, 2004 7:15 pm   Post subject: (No subject)

It depends on how you want to do it. In some cases, you could just have the loop inside another loop. But that'd be weird for me to explain, and if you wanted to use the loop somewhere else instead of immediately after it finishes, that'd be useless.
What I'm thinking would be best is to have a proc with the loop that you call whenever necessary.
code:

proc loopstuff
    loop
        % stuff happens here!
        exit % make sure you exit sometime
    end loop
end loopstuff

loopstuff
put "That was... 'fun'"
loopstuff
put "OK, that's enough."
[/code]
RottenPunk




PostPosted: Thu Feb 19, 2004 7:18 pm   Post subject: (No subject)

im pretty new with turing too and i wasn't sure of a command to restart a loop in an if statement either but in one of my programs i fund that i put something like the following:

code:
get retry
if retry="n" or retry="N" then
exit
end if

this tells the program that if the input is n or N than the program terminates but if anything else is typed the loop starts over. at leaset that is how mine works. hope that helps
ashan




PostPosted: Thu Feb 19, 2004 7:42 pm   Post subject: thanks, that works

hey,

thanks man!

that works!

u guys are great!!

thanks again

ashan
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: