Changes don't appear on the screen while a loop is running

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
MichaelBluejay
Posts: 234
Joined: Thu Jul 01, 2010 11:50 am

Changes don't appear on the screen while a loop is running

Post by MichaelBluejay » Tue Dec 14, 2010 11:03 pm

When I do something simple like this:

Code: Select all

set lockscreen to false
   repeat forever
   put the seconds into field 1
end repeat
...the changes don't appear on the screen. As soon as I abort the script I can see the updated time.

How can I get the changes to show?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Changes don't appear on the screen while a loop is running

Post by mwieder » Wed Dec 15, 2010 1:50 am

/home/mwieder/Desktop/MetaCard/Toolset/mchome.mc
First of all, I would never do that. Ever.

You need to give yourself a way out of the repeat loop (mouseDown is one way)
Second, you're not giving the screen time to update. Your tight repeat loop is taking up all the cpu cycles. You need to tell it to free up some time for other tasks, and the "with messages" part of the otherwise do-nothing call below will do just that.

Try this

Code: Select all

   set the lockscreen to false
   repeat while the mouse is up
      put the seconds into field 1
      wait 0 seconds with messages
   end repeat

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Changes don't appear on the screen while a loop is running

Post by Klaus » Wed Dec 15, 2010 11:24 am

mwieder wrote:
/home/mwieder/Desktop/MetaCard/Toolset/mchome.mc
??? :shock:

:D

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Changes don't appear on the screen while a loop is running

Post by mwieder » Wed Dec 15, 2010 4:55 pm

Um.

Note to self: Copy *before* Paste...

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Changes don't appear on the screen while a loop is running

Post by Klaus » Wed Dec 15, 2010 5:33 pm

mwieder wrote:Um.
Note to self: Copy *before* Paste...
Sounds like a good idea :D

MichaelBluejay
Posts: 234
Joined: Thu Jul 01, 2010 11:50 am

Re: Changes don't appear on the screen while a loop is running

Post by MichaelBluejay » Thu Dec 16, 2010 8:31 am

Great, thanks for the help!

Post Reply