Slow Fields and Handler Haunts

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

Luisa Klose
Posts: 48
Joined: Tue Aug 30, 2011 2:24 pm

Slow Fields and Handler Haunts

Post by Luisa Klose » Tue Aug 30, 2011 3:15 pm

Getting seriously into the Windows trial version of LiveCode after a tip on Adobe's Director User Forums. I'm comfortable with Director and finding LiveCode very accessible and surprisingly similar to Lingo.

I translated a calculator (with considerably more functionality than the one in the Resource Center) that I wrote recently in Director Lingo. It works beautifully but the number input is slow. There is a noticeable lag between the button press and when the number appears in the field. I'm wondering if there's a problem with the way I have structured things.

At the moment, I have 20 custom handlers with 8 global variables in the main stack script. And I call them from the button's mouseUp script. The handler that processes the numbers goes like this:

Code: Select all

on handleNumber thisOne
put thisOne into field "display"
end handleNumber
And the mouseUp script:

Code: Select all

on mouseUp
handleNumber 7
end mouseUp
I looked at all of the field's properties and nothing graphic intensive...

One more question: after purchasing LiveCode, can I install it and author on both Mac and Windows, or would I have to buy it 2x?

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

Re: Slow Fields and Handler Haunts

Post by Klaus » Tue Aug 30, 2011 4:26 pm

Hi Luisa,

1. Welcome to the forum!
2. Yes, you can install LiveCode on all of your development machines, as long as you only use one machine at a time :D
3. No idea what is slowing your simple scripts down? Should not happen!
Any "background" processes going on?

I could offer to take a quick look at the stack!
Send it (or a stripped down version) to klaus (AT) major-k.de if you like :)


Best

Klaus

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Slow Fields and Handler Haunts

Post by Dixie » Tue Aug 30, 2011 4:31 pm

hi...

Do you want to post your stack ?

be well

Dixie

Luisa Klose
Posts: 48
Joined: Tue Aug 30, 2011 2:24 pm

Re: Slow Fields and Handler Haunts

Post by Luisa Klose » Tue Aug 30, 2011 11:37 pm

Thanks for responding, Klaus and Dixie. Would have responded sooner but I was away from my computer.

Here's my stack guys, don't mess with it. Just kidding ;)

I stripped all the scripts away except for the relevant one. Only the number buttons work; all the other buttons will produce an error. To see what I mean by slow field, press a number quickly a few times.

Thanks.
Attachments
Luisa Klose calculator.zip
I uploaded this file zipped because I was informed by the BB software that the extension livecode is not allowed.
(3.03 KiB) Downloaded 276 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Slow Fields and Handler Haunts

Post by dunbarx » Wed Aug 31, 2011 12:07 am

I see an ordinary response to button presses. No delays...

OSX10.4.11, LC 4.5.3.

Craig Newman

Luisa Klose
Posts: 48
Joined: Tue Aug 30, 2011 2:24 pm

Re: Slow Fields and Handler Haunts

Post by Luisa Klose » Wed Aug 31, 2011 12:12 am

I'm on Windows 7 with a fairly zippy computer. Anyway, it's good to know that the handler runs well on the Mac. Thanks, Craig.

Luisa Klose
Posts: 48
Joined: Tue Aug 30, 2011 2:24 pm

Re: Slow Fields and Handler Haunts

Post by Luisa Klose » Wed Aug 31, 2011 12:23 am

By the way, here is an earlier version of the calculator, in Shockwave format. If you're using Firefox on Windows, it may crash when using the "paste" function and/or after displaying the alert box that the "help" button displays. It works well for me in IE 9.

www axiomx com/calculator/calculator_final_shockwave htm

And here is some source code from software I created with Director. I'm hoping to translate at least a couple of these into LiveCode. Free graphics too. No ads, nags, spying, or strings attached. Enjoy.

www axiomx com/algorithms htm

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Slow Fields and Handler Haunts

Post by Dixie » Wed Aug 31, 2011 12:29 am

Hi...

I am afraid that I found the same as Craig... runs fine on a Mac OSX 10.6.8 & 10.7.1, LiveCode 4.6.3... The numbers also play nicely under Windows XP.

be well

Dixie

Luisa Klose
Posts: 48
Joined: Tue Aug 30, 2011 2:24 pm

Re: Slow Fields and Handler Haunts

Post by Luisa Klose » Wed Aug 31, 2011 12:33 am

Thanks, Dixie, I wonder if it has something to do with the desktop compositing monster.

Luisa Klose
Posts: 48
Joined: Tue Aug 30, 2011 2:24 pm

Re: Slow Fields and Handler Haunts

Post by Luisa Klose » Wed Aug 31, 2011 12:36 am

The calculator in the Resource Center doesn't have the same problem. That's why I thought that the difference was perhaps where I put the code.

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

Re: Slow Fields and Handler Haunts

Post by mwieder » Wed Aug 31, 2011 6:42 am

I can't see any slowdown on linux, OSX, or xp. As a general rule your code will run faster if you bracket any screen updates with lock/unlock screen, but I don't notice this being any slower without that.

Code: Select all

on handleNumber thisValue
  lock screen
  -- do the handleNumber thing
  unlock screen
end handleNumber

kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

Re: Slow Fields and Handler Haunts

Post by kevin11 » Wed Aug 31, 2011 10:25 am

Runs fast for me on Windows XP.

I notice however if you hit the same number quickly sometimes you get a few digits quickly, then a very very short pause, and then it continues. There can occasionally be a slight lag between hitting the number and it appearing. As I have the same little pause within my own stack (when sliding an image), I suspect some background process is interrupting very briefly at high priority.

Luisa Klose
Posts: 48
Joined: Tue Aug 30, 2011 2:24 pm

Re: Slow Fields and Handler Haunts

Post by Luisa Klose » Wed Aug 31, 2011 3:43 pm

Thanks, kevin11 and mweider.

As I mentioned, the simple calculator in the resource center doesn't have the same problem.

I just created a stack put a field in it and a button with this on mouseUp: put the label of the target after field "display". And it's slow.

In my estimation, it's either something in the simple calculator that makes it run faster, or perhaps it's the file type (.rev vs .livecode), or the fact that I'm on a trial version.

Sure would be nice to know what the problem is. I don't want my future apps to have slow fields.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Slow Fields and Handler Haunts

Post by Dixie » Wed Aug 31, 2011 4:29 pm

Hi...

I have attached a stack that uses your script to display the 'label of the target' into a fld 'display. Under OSX the time it returns to complete varies between 3 - 10 millisecs, surprisingly (to me anyway) the time it takes to complete under Windows XP is 0 millisecs...

Code: Select all

on mouseUp
   put the millisecs into tstart
   --put the label of the target after fld "display"
   put the label of the target into fld "display"
   put the millisecs - tstart
end mouseUp
I don't think that it would be anything in the 'simple calculator' stack that makes it run faster !... :) and the liveCode trial version is exactly the same as a licensed version... It will be interesting to see what the millisec count is when running on your box under windows 7.

be well

Dixie
Attachments
time.livecode.zip
(966 Bytes) Downloaded 245 times

Luisa Klose
Posts: 48
Joined: Tue Aug 30, 2011 2:24 pm

Re: Slow Fields and Handler Haunts

Post by Luisa Klose » Wed Aug 31, 2011 4:51 pm

Dixie, I believe that times the handler, not the time it takes for its result to make it to the screen.

I stand by my observations. Thanks.

Post Reply