Most Efficient Method?

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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Most Efficient Method?

Post by richmond62 » Wed Feb 27, 2019 1:33 pm

Call a commonly used routine from a BUTTON, FIELD or CUSTOM PROPERTY?
-
Effish.png
Attachments
Efficiency Q.livecode.zip
Here's the stack.
(1.51 KiB) Downloaded 151 times

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Most Efficient Method?

Post by bogs » Wed Feb 27, 2019 1:45 pm

Actually, wouldn't the more efficient way to do this be

Code: Select all

set the backGroundColor of btn "B2" to red
send "set the backGroundColor of btn "B2" to blue" to this stack in 2 seconds
...Or at least, the less blocking version I guess...

As far as running the sample goes, I had the following results -
* click the 'do button' button, worked
* click the 'do field' button produced the following error -

Code: Select all

button "Do FIELD": execution error at line 2 (do: error in source expression) near "set the backGroundColor of btn "B2" to red", char 1
* click the 'do cust.prop' button worked
* click the script button worked.

Edit - for those of us that are modern challenged, may want to include the least version it will work in as well
:D
Last edited by bogs on Wed Feb 27, 2019 1:51 pm, edited 2 times in total.
Image

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Most Efficient Method?

Post by Klaus » Wed Feb 27, 2019 1:46 pm

Most effective is to put this into a handler in the card or stack script:

Code: Select all

command your_fancy_stuff
   set the backGroundColor of btn "B1" to red
   wait 2 secs
   set the backGroundColor of btn "B1" to blue
end your_fancy_stuff
And just execute it when clicking the button or field:

Code: Select all

on mouseup
  your_fancy_stuff
end mouseup
Using a Custom Property this way does not seem to be effective at all.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Most Efficient Method?

Post by richmond62 » Wed Feb 27, 2019 3:37 pm

Thanks Klaus.

I made this stack using LiveCode 8.1.10 on macOS 10.14.

The "Do FIELD" button works under those parameters.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Most Efficient Method?

Post by Klaus » Wed Feb 27, 2019 3:59 pm

richmond62 wrote:
Wed Feb 27, 2019 3:37 pm
Thanks Klaus.

I made this stack using LiveCode 8.1.10 on macOS 10.14.

The "Do FIELD" button works under those parameters.
Sure, but "do" is always slower than direct access/execution of the script.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Most Efficient Method?

Post by richmond62 » Wed Feb 27, 2019 4:09 pm

"do" is always slower
It's just been one of those zippy-de-doo-da days:

https://www.youtube.com/watch?v=6bWyhj7siEY

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”