Loop not exiting?
Author |
Message |
yeyavailability
|
Posted: Mon Jun 09, 2008 1:17 pm Post subject: Loop not exiting? |
|
|
Turing: |
procedure selecttrack_click (x1, x2, y1, y2 : int)
var mx, my, mb : int
loop
Mouse.Where (mx, my, mb )
if mx >= x1 and mx <= y1 and my >= x2 and my <= y2 and mb = 1
then
drawfillbox (8, 468, 12, 472, black) %Creates selection
drawfillbox (93, 468, 97, 472, white) %From here onward--clears other selections
drawfillbox (178, 468, 182, 472, white)
drawfillbox (263, 468, 267, 472, white)
drawfillbox (348, 468, 352, 472, white)
drawfillbox (433, 468, 437, 472, white)
loop
fork music1
exit when mx >= x1 + 85 and mx <= y1 + 85 and my >= x2 and my <= y2 and mb = 1 or
mx >= x1 + 170 and mx <= y1 + 170 and my >= x2 and my <= y2 and mb = 1 or
mx >= x1 + 255 and mx <= y1 + 255 and my >= x2 and my <= y2 and mb = 1 or
mx >= x1 + 340 and mx <= y1 + 340 and my >= x2 and my <= y2 and mb = 1 or
mx >= x1 + 425 and mx <= y1 + 425 and my >= x2 and my <= y2 and mb = 1
end loop
elsif mx >= x1 + 85 and mx <= y1 + 85 and my >= x2 and my <= y2 and mb = 1
then
drawfillbox (93, 468, 97, 472, black) %Creates selection
drawfillbox (8, 468, 12, 472, white) %From here onward--clears other selections
drawfillbox (178, 468, 182, 472, white)
drawfillbox (263, 468, 267, 472, white)
drawfillbox (348, 468, 352, 472, white)
drawfillbox (433, 468, 437, 472, white)
fork music2
elsif mx >= x1 + 170 and mx <= y1 + 170 and my >= x2 and my <= y2 and mb = 1
then
drawfillbox (178, 468, 182, 472, black) %Creates selection
drawfillbox (8, 468, 12, 472, white) %From here onward--clears other selections
drawfillbox (93, 468, 97, 472, white)
drawfillbox (263, 468, 267, 472, white)
drawfillbox (348, 468, 352, 472, white)
drawfillbox (433, 468, 437, 472, white)
fork music3
elsif mx >= x1 + 255 and mx <= y1 + 255 and my >= x2 and my <= y2 and mb = 1
then
drawfillbox (263, 468, 267, 472, black) %Creates selection
drawfillbox (93, 468, 97, 472, white) %From here onward--clears other selections
drawfillbox (178, 468, 182, 472, white)
drawfillbox (8, 468, 12, 472, white)
drawfillbox (348, 468, 352, 472, white)
drawfillbox (433, 468, 437, 472, white)
fork music4
elsif mx >= x1 + 340 and mx <= y1 + 340 and my >= x2 and my <= y2 and mb = 1
then
drawfillbox (348, 468, 352, 472, black) %Creates selection
drawfillbox (93, 468, 97, 472, white) %From here onward--clears other selections
drawfillbox (178, 468, 182, 472, white)
drawfillbox (263, 468, 267, 472, white)
drawfillbox (8, 468, 12, 472, white)
drawfillbox (433, 468, 437, 472, white)
fork music5
elsif mx >= x1 + 425 and mx <= y1 + 425 and my >= x2 and my <= y2 and mb = 1
then
drawfillbox (433, 468, 437, 472, black) %Creates selection
drawfillbox (93, 468, 97, 472, white) %From here onward--clears other selections
drawfillbox (178, 468, 182, 472, white)
drawfillbox (263, 468, 267, 472, white)
drawfillbox (8, 468, 12, 472, white)
drawfillbox (348, 468, 352, 472, white)
Music.PlayFileStop
end if
exit when mx >= x1 and mx <= y1 and my >= x2 and my <= y2 and mb = 1 or %Declare end loop conditions
mx >= x1 + 85 and mx <= y1 + 85 and my >= x2 and my <= y2 and mb = 1 or
mx >= x1 + 170 and mx <= y1 + 170 and my >= x2 and my <= y2 and mb = 1 or
mx >= x1 + 255 and mx <= y1 + 255 and my >= x2 and my <= y2 and mb = 1 or
mx >= x1 + 340 and mx <= y1 + 340 and my >= x2 and my <= y2 and mb = 1 or
mx >= x1 + 425 and mx <= y1 + 425 and my >= x2 and my <= y2 and mb = 1
end loop
end selecttrack_click
|
It's the first one with the music1 music that I'm trying to understand before I try looping anything else. Basically, if the mouse is at the specified spot, the program will put a black box in a fake checkbox and put white boxes everywhere else to give the illusion of selection. Anyways, the music tracks I've chosen are pretty short--they're the beginnings of random songs. I want to make the song keep playing until I select another track. The problem is that even though I've put down all my 'exit when' situations, the loop won't exit and I am unable to choose any other track. What is wrong with my code? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Insectoid

|
Posted: Mon Jun 09, 2008 3:42 pm Post subject: Re: Loop not exiting? |
|
|
I believe the problem is that there has to be brackets around everything between the 'or's. Turing follows things sequentially, you have to specifically mark the spots where you want it to deviate from the sequence. so it should look like this:
code: |
exit when (mx >= x1 and mx <= y1 and my >= x2 and my <= y2 and mb = 1) or %Declare end loop conditions
(mx >= x1 + 85 and mx <= y1 + 85 and my >= x2 and my <= y2 and mb = 1) or
(mx >= x1 + 170 and mx <= y1 + 170 and my >= x2 and my <= y2 and mb = 1 )or
(mx >= x1 + 255 and mx <= y1 + 255 and my >= x2 and my <= y2 and mb = 1 )or
(mx >= x1 + 340 and mx <= y1 + 340 and my >= x2 and my <= y2 and mb = 1 )or
(mx >= x1 + 425 and mx <= y1 + 425 and my >= x2 and my <= y2 and mb = 1)
|
or you could have 6 exit when statements.
code: |
exit when mx >= x1 and mx <= y1 and my >= x2 and my <= y2 and mb = 1
exit when mx >= x1 + 85 and mx <= y1 + 85 and my >= x2 and my <= y2 and mb = 1
exit when mx >= x1 + 170 and mx <= y1 + 170 and my >= x2 and my <= y2 and mb = 1
exit when mx >= x1 + 255 and mx <= y1 + 255 and my >= x2 and my <= y2 and mb = 1
exit when mx >= x1 + 340 and mx <= y1 + 340 and my >= x2 and my <= y2 and mb = 1
exit when mx >= x1 + 425 and mx <= y1 + 425 and my >= x2 and my <= y2 and mb = 1
|
I know for a fact the bottom one works. The first one would be more efficient (I think...), and it would look cooler! |
|
|
|
|
 |
|
|