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

Username:   Password: 
 RegisterRegister   
 Loop Syntax Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Chromaticci




PostPosted: Mon May 23, 2011 5:25 pm   Post subject: Loop Syntax Help

What is it you are trying to achieve?
A smoothly running program that continues reading the code after the end loop.

What is the problem you are having?
I have a code and it runs smoothly up until my end loop command. Then the program no longer reads anything after that.

Describe what you have tried to solve this problem
I am assuming it's a stupid syntax error so I've been googling "Turing Syntax Help" and the similar searches into my search engine. In hope that there are others with similar problems. So far, no luck.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
And here is my current code work, I've removed the music and extras to keep the code short: The original snow code does not belong to me.

Turing:

setscreen ("nobuttonbar")
setscreen ("noecho")
setscreen ("nocursor")
setscreen ("graphics:680;500")

var sx : array 1 .. 300 of int
var sy : array 1 .. 300 of int
for snow : 1 .. 300
    sx (snow) := Rand.Int (0, maxx)
    sy (snow) := Rand.Int (0, maxy)
end for

loop
    Draw.FillBox (0, 0, maxx, maxy, 18)
    for snow : 1 .. 300
        sy (snow) -= Rand.Int (0, 5)
        Draw.FillOval (sx (snow), sy (snow), 2, 2, white)
    end for
delay (20)
end loop

/*What I want to shown*/
var Header: int
Header := Font.New ("Rockwell Extra Bold:30:bold")
Font.Draw ("TEXTEXTEXTEXT", 115, maxy - 80, iHeader, white)



Please specify what version of Turing you are using
The most recent one available @ Holtsoft
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Mon May 23, 2011 5:31 pm   Post subject: RE:Loop Syntax Help

Umm... Is the ID in your Font.Draw supposed to be iHeader?
Raknarg




PostPosted: Mon May 23, 2011 5:32 pm   Post subject: RE:Loop Syntax Help

Oh, whoops. Also, there's no exit when statement. Thats the condition you set for the loop to finish.
Chromaticci




PostPosted: Mon May 23, 2011 5:39 pm   Post subject: Re: RE:Loop Syntax Help

Raknarg @ Mon May 23, 2011 5:32 pm wrote:
Oh, whoops. Also, there's no exit when statement. Thats the condition you set for the loop to finish.

I've tried placing an exit before "end loop" but that just makes the entire code not move...Erm the snow part.
Oh it is supposed to be iHeader but I must have erased it by accident :c
Tony




PostPosted: Mon May 23, 2011 5:50 pm   Post subject: RE:Loop Syntax Help

What Raknarg is saying is that since the loop never exits, it just keeps on repeated indefinitely, and never gets to "/*What I want to shown*/" part.

But if you do exit the loop, then that part stops repeating, so naturally no new animation screens would be drawn.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Raknarg




PostPosted: Mon May 23, 2011 6:07 pm   Post subject: RE:Loop Syntax Help

Turing:

loop
     number := number + 1
     exit when number = 5
end loop


That's how you would use exit when. You could do something similar in your case.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: