Opening a stack causes malfunctions?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
user99
Posts: 5
Joined: Sat May 03, 2014 2:05 pm

Opening a stack causes malfunctions?

Post by user99 » Sat May 03, 2014 2:13 pm

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.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Opening a stack causes malfunctions?

Post by jmburnod » Sat May 03, 2014 2:36 pm

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
https://alternatic.ch

user99
Posts: 5
Joined: Sat May 03, 2014 2:05 pm

Re: Opening a stack causes malfunctions?

Post by user99 » Sat May 03, 2014 2:41 pm

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.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Opening a stack causes malfunctions?

Post by jmburnod » Sat May 03, 2014 3:04 pm

Here is a simple Timer using pendingmessages
I hope its help in your case
Attachments
TimerSendInTime.livecode.zip
(1.52 KiB) Downloaded 177 times
https://alternatic.ch

user99
Posts: 5
Joined: Sat May 03, 2014 2:05 pm

Re: Opening a stack causes malfunctions?

Post by user99 » Sat May 03, 2014 3:22 pm

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.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Opening a stack causes malfunctions?

Post by jmburnod » Sat May 03, 2014 4:30 pm

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
https://alternatic.ch

user99
Posts: 5
Joined: Sat May 03, 2014 2:05 pm

Re: Opening a stack causes malfunctions?

Post by user99 » Sat May 03, 2014 5:09 pm

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!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Opening a stack causes malfunctions?

Post by jacque » Sat May 03, 2014 5:23 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

user99
Posts: 5
Joined: Sat May 03, 2014 2:05 pm

Re: Opening a stack causes malfunctions?

Post by user99 » Sat May 03, 2014 5:42 pm

It worked. Thanks again.

Post Reply