Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 7th_zorro), 923 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
while loop not working #463492
12/07/16 22:46
12/07/16 22:46
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
I'm wondering if maybe my script is just too long to run properly, because I am getting some strange errors.

Quote:
while(1)
{
if(message_mship < 101)
{
toggle(mship_approach_pan,SHOW);
message_mship += 10;
}
else
{
message_mship = 0;
reset(mship_approach_pan,SHOW);
return;
}

wait(-.25);
}


This while loop gets stuck with the variable "message_mship" set at 11. It should keep looping until it eventually reaches 101, right? It worked in another function for a different flashing panel which is exactly pretty much the same function. I'm wondering if maybe my game's script is just too long and it's somehow forgetting to run through this particular loop.

Is that possible? Other loops in the same .c file seem to work fine though.

I've tried making the wait (1) instead of (-.25) but I get the same results. I've looked for any external function that might be resetting "message_mship" to 1, but can't find any. I've also tried using a different variable, just in case, but that doesn't work either...

Re: while loop not working [Re: Dooley] #463493
12/07/16 22:49
12/07/16 22:49
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
I've also rewritten the loop like this...
Quote:

while(message_mship < 101)
{
toggle(mship_approach_pan,SHOW);
message_mship += 10;
wait(-.25);
}

message_mship = 0;
reset(mship_approach_pan,SHOW);

Re: while loop not working [Re: Dooley] #463497
12/08/16 03:59
12/08/16 03:59
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
I figured it out ...

The function that called the function with the loop ends before the loop finishes, and that's why it gets stuck.

I'm pretty sure I encountered this before, and did not realize it until I found the cause.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1