So I'm coding a spin box to use in a sound test script, and whenever I test the script, I get a visit from Dr. Watson32 ("GAME.EXE has encountered a problem and needs to close.")
script,spin box,begin
suspend player
variable(holder, sl, choice)
holder := create rect(50,40,0)
set horiz align(holder, edge:center)
set vert align(holder, edge:center)
set horiz anchor(holder, edge:center)
set vert anchor(holder, edge:center)
sl := create text
set horiz align(sl, edge:center)
set vert align(sl, edge:center)
set horiz anchor(sl, edge:center)
set vert anchor(sl, edge:center)
while(not(keyispressed(key:Esc))) do(
if(choice << 10) then ($31 := "00") else (if(choice << 100) then ($31:="0"))
append number(31, choice)
set slice text(sl,31)
)
free slice(holder)
resume player
end
That while loop looks infinite to me. If there is no wait of any kind in the while loop, it never gets a chance to poll the keyboard, so it never gets a chance to read any new ESC keypresses.
Although I would expect that to cause game.exe to stop responding, not to crash.
Also, "append number" adds the number to the end of the string, so you should clear the string first. Actually, maybe it is crashing because the infinite loop makes the string incredibly long very fast, and it overflows some memory or something?
Last edited by Bob the Hamster on Fri Jan 14, 2011 6:51 pm, edited 1 time in total.