 |
Mythic Newbie
Joined: 09 Mar 2001 Posts: 6 Location: USA
|
Posted: Wed Mar 17, 2004 8:46 am
frustrating infinite loop |
I'm either really stupid, or stoned, because I canNOT figure out why this is looping infinitely. Suicide is lookin good, so please help me! [:(!]
#CLASS {Roundtime}
#VAR rt {} {}
#VAR rt2 {} {}
#VAR RTMax {} {}
#VAR RoundTime {} {}
#VAR temp {} {}
#TRIGGER {Q} {
#var rt %gsl( Q) "" "RoundTime"
#var rt2 %gsl( q) "" "RoundTime"
#var RoundTime "" "" "RoundTime"
#math RoundTime (@rt - @rt2)
#var RTMax @RoundTime "" "RoundTime"
#var temp @RoundTime "" "RoundTime"
#until (@Temp <= 0) {
#var @{Temp}Temp @Temp "" "RoundTime"
#alarm {+@{Temp}Temp} {#add RoundTime -1} RoundTime
** I'm decrementing from this variable, so I shouldn't be getting an infinite looP! ***
#add @temp (-1)
}
} "" {gsl|case}
#BUTTON 1 {} {} {RoundTime} {} {@RoundTime} {@RoundTime} {} {Size} {150} {11} {} {} {} {32832} {} {Gauge||7|@RTMax|0|0} {} "" {Explore|Inset} {} {}
#CLASS 0
THanks
-Mythic |
|
|
 |
Kjata GURU

Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Wed Mar 17, 2004 12:55 pm |
The syntax for #ADD does not include the @ for the variable it modifies. It should be:
#ADD temp -1 |
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed Mar 17, 2004 7:21 pm |
It's looping infinitely because you have an UNTIL loop based on a variable which is changed by an alarm rather than the loop. The loop is much faster than your alarm and the infinite-loop detector is likely to kick in no matter how short the alarm time is (minimum alarm-time is half-a-second).
In addition, your alarm time is +@{Temp}Temp, which will be a string (+5Temp, for instance, if @Temp is 5) rather than the number that's expected, so it's unlikely that your alarm will even work. You probably meant to use +@{@{Temp}Temp}, but I can't see any reason to use a variable for the alarm time at all. You clearly intend the alarm to measure a fixed period of time (probably one second), so it would be better to just use the correct number for that time.
Finally, there's the error Kjata pointed out, which means you never decrement the UNTIL variable.
#CLASS {Roundtime}
#VAR rt {} {}
#VAR rt2 {} {}
#VAR RTMax {} {}
#VAR RoundTime {} {}
#VAR temp {} {}
#TRIGGER {Q} {
#var rt %gsl( Q) "" "RoundTime"
#var rt2 %gsl( q) "" "RoundTime"
#var RoundTime "" "" "RoundTime"
#math RoundTime (@rt - @rt2)
#var RTMax @RoundTime "" "RoundTime"
#var temp @RoundTime "" "RoundTime"
#ALA RTalarm *1 {
#IF (@temp > 0) {
#ADD RoundTime -1
#ADD temp -1
} {#UNTR RTalarm}
}
} "" {gsl|case}
#BUTTON 1 {} {} {RoundTime} {} {@RoundTime} {@RoundTime} {} {Size} {150} {11} {} {} {} {32832} {} {Gauge||7|@RTMax|0|0} {} "" {Explore|Inset} {} {}
#CLASS 0 |
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|