Author |
Message |
SAValkyrie
|
Posted: Thu Nov 01, 2012 7:48 pm Post subject: Need Help with Turing |
|
|
What is it you are trying to achieve?
Trying to write a program that endlessly tells you to "Have a good day"
Tr y stopping execution. Change it so that it is a program to wish you a good day only six times.
What is the problem you are having?
I got the "Have a good day" part but I cannot figure you the only six times part. With my knowledge, the only thing i can do is to state the word that can stop the execution. Is there a way to stop it when it counts 6 times?
Please specify what version of Turing you are using
Turing 4.1.2 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
chipanpriest

|
Posted: Thu Nov 01, 2012 7:58 pm Post subject: Re: Need Help with Turing |
|
|
Either look into increments. or if you're really adventurous, look into for statements.
I'll give you this much, to exit a loop, you can type "exit when". Eg.
Turing: |
loop
exit when %whatever
end loop
|
You can set the whatever to anything you want, which can help in your situation.
Think about it, if you want the loop to exit after 6 times, how would you get the loop to count? |
|
|
|
|
 |
SAValkyrie
|
Posted: Thu Nov 01, 2012 8:22 pm Post subject: Re: Need Help with Turing |
|
|
Is the use of count appropriate in this situation?[/syntax] |
|
|
|
|
 |
Tony

|
Posted: Thu Nov 01, 2012 8:33 pm Post subject: RE:Need Help with Turing |
|
|
Yes, you can use for-loops to execute a piece of code a specific number of times. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
SAValkyrie
|
Posted: Thu Nov 01, 2012 8:36 pm Post subject: Re: Need Help with Turing |
|
|
Turing: |
var count: int
count:= 0
loop
count:=count+ 1
put "Have a good day"
exit when count= 6
Time.Delay(500)
end loop
|
ah i got it[/syntax][/quote] |
|
|
|
|
 |
chipanpriest

|
Posted: Fri Nov 02, 2012 5:25 am Post subject: Re: Need Help with Turing |
|
|
LOL your second comment was different than your first. Both work though. You could use a for statement:
Turing: |
for count : 1 .. 6
put "Have a good day!"
Time.Delay (500)
end for
|
I like this better but both ways work. |
|
|
|
|
 |
|