Page 1 of 2

Slow Fields and Handler Haunts

Posted: Tue Aug 30, 2011 3:15 pm
by Luisa Klose
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?

Re: Slow Fields and Handler Haunts

Posted: Tue Aug 30, 2011 4:26 pm
by Klaus
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

Re: Slow Fields and Handler Haunts

Posted: Tue Aug 30, 2011 4:31 pm
by Dixie
hi...

Do you want to post your stack ?

be well

Dixie

Re: Slow Fields and Handler Haunts

Posted: Tue Aug 30, 2011 11:37 pm
by Luisa Klose
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.

Re: Slow Fields and Handler Haunts

Posted: Wed Aug 31, 2011 12:07 am
by dunbarx
I see an ordinary response to button presses. No delays...

OSX10.4.11, LC 4.5.3.

Craig Newman

Re: Slow Fields and Handler Haunts

Posted: Wed Aug 31, 2011 12:12 am
by Luisa Klose
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.

Re: Slow Fields and Handler Haunts

Posted: Wed Aug 31, 2011 12:23 am
by Luisa Klose
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

Re: Slow Fields and Handler Haunts

Posted: Wed Aug 31, 2011 12:29 am
by Dixie
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

Re: Slow Fields and Handler Haunts

Posted: Wed Aug 31, 2011 12:33 am
by Luisa Klose
Thanks, Dixie, I wonder if it has something to do with the desktop compositing monster.

Re: Slow Fields and Handler Haunts

Posted: Wed Aug 31, 2011 12:36 am
by Luisa Klose
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.

Re: Slow Fields and Handler Haunts

Posted: Wed Aug 31, 2011 6:42 am
by mwieder
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

Re: Slow Fields and Handler Haunts

Posted: Wed Aug 31, 2011 10:25 am
by kevin11
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.

Re: Slow Fields and Handler Haunts

Posted: Wed Aug 31, 2011 3:43 pm
by Luisa Klose
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.

Re: Slow Fields and Handler Haunts

Posted: Wed Aug 31, 2011 4:29 pm
by Dixie
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

Re: Slow Fields and Handler Haunts

Posted: Wed Aug 31, 2011 4:51 pm
by Luisa Klose
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.