Page 1 of 1
Opening a stack causes malfunctions?
Posted: Sat May 03, 2014 2:13 pm
by user99
Hello. I have been working with livecode for a game programming unit and have come across a reoccurring problem. Whenever I open my game, I cannot select anything and the entire program is frozen until I try to close it. Then I am redirected to the faulty code which I have created for a timer in my game. After this, the program is still in a frozen state and stops responding. I cannot edit anything in the stack so it keeps happening every time I try to open it. I'm very worried as I have spent a lot of time creating this game and now it has been made redundant by some bad code. Could anybody please help me out? I would link an image of the program in it's frozen state but it appears I am unable to do that as my account does not have the permissions. Here is the code that is targeted:
on timer x
repeat
subtract x from TimeLeft
put TimeLeft into TimeLeftoutput
wait 1 second
end repeat
end timer
TimeLeft is a local value. The error code displayed by the program targets the line "wait 1 second" with the error code - "card "card id 1002": execution error at line 72 (wait: aborted), char 1"
EDIT: It's also worth noting that this has happened on another machine other than my home computer.
Re: Opening a stack causes malfunctions?
Posted: Sat May 03, 2014 2:36 pm
by jmburnod
Hi user99
Using a repeat loop for a timer is not a good way
Using pendingmessages is better.
If you choose repeat you have to put "with messages" after your wait message like this:
Code: Select all
on timer x
repeat
subtract x from TimeLeft
put TimeLeft into TimeLeftoutput
wait 1 second with messages
end repeat
end timer
Best regards
Jean-Marc
Re: Opening a stack causes malfunctions?
Posted: Sat May 03, 2014 2:41 pm
by user99
jmburnod wrote:Hi user99
Using a repeat loop for a timer is not a good way
Using pendingmessages is better.
If you choose repeat you have to put "with messages" after your wait message like this:
Code: Select all
on timer x
repeat
subtract x from TimeLeft
put TimeLeft into TimeLeftoutput
wait 1 second with messages
end repeat
end timer
Best regards
Jean-Marc
Thank you, but I can't edit the code at all since the program will freeze up when I try to open the stack.
Re: Opening a stack causes malfunctions?
Posted: Sat May 03, 2014 3:04 pm
by jmburnod
Here is a simple Timer using pendingmessages
I hope its help in your case
Re: Opening a stack causes malfunctions?
Posted: Sat May 03, 2014 3:22 pm
by user99
jmburnod wrote:Here is a simple Timer using pendingmessages
I hope its help in your case
Sorry, I don't think you quite understand my dilemma. My main stack will freeze the program upon opening, meaning I cannot edit anything in the entire stack. I'm led to believe that the code mentioned is causing this, but I cannot do anything about it since the program is frozen every time.
Re: Opening a stack causes malfunctions?
Posted: Sat May 03, 2014 4:30 pm
by jmburnod
My main stack will freeze the program upon opening, meaning I cannot edit anything in the entire stack
OK. Try this
create a new stack with one btn with this script:
Code: Select all
on mouseUp
answer file "open" -- select your stack
if it = empty then exit mouseup
set the lockmessages to true
open stack it
set the lockmessages to false
end mouseUp
Re: Opening a stack causes malfunctions?
Posted: Sat May 03, 2014 5:09 pm
by user99
jmburnod wrote:My main stack will freeze the program upon opening, meaning I cannot edit anything in the entire stack
OK. Try this
create a new stack with one btn with this script:
Code: Select all
on mouseUp
answer file "open" -- select your stack
if it = empty then exit mouseup
set the lockmessages to true
open stack it
set the lockmessages to false
end mouseUp
I shall try this. Thanks very much!
Re: Opening a stack causes malfunctions?
Posted: Sat May 03, 2014 5:23 pm
by jacque
It is easier to just click the icon in the top toolbar named "Messages". When that icon is bold, none of your scripts will run. You don't need to write any scripts. Remember to turn messages back on when the stack is read to test and run again.
You need to turn off messaging before you open the stack, otherwise you won't get a chance to do it.
Re: Opening a stack causes malfunctions?
Posted: Sat May 03, 2014 5:42 pm
by user99
It worked. Thanks again.