Getting livecode to execute a statement contained in a strin

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bergsy
Posts: 45
Joined: Mon Oct 28, 2013 10:51 pm

Getting livecode to execute a statement contained in a strin

Post by bergsy » Tue Jul 01, 2014 7:53 am

Hi,

I have a piece of code that constructs a Livecode statement in a string that I would then like to execute, but I don't know how to do it or if it is possible

My code is as follows:

put "btnContinue" into myBtn
put "Continue to next screen" into myToolTip
put "set the ToolTip of btn " & myBtn & " to " & quote & myToolTip & quote into myCmd
myCmd


I was hoping that "myCmd" would execute the string contents which are:
set the ToolTip of btn btnContinue to "Continue to next screen"

The reason why I would like to do this is to have different tooltips for different buttons set up in an array so that I can change them dynamically depending on the status of the application.

Any assistance would be appreciated

Cheers

bergsy

bergsy
Posts: 45
Joined: Mon Oct 28, 2013 10:51 pm

Re: Getting livecode to execute a statement contained in a s

Post by bergsy » Tue Jul 01, 2014 8:04 am

Figured it out:

do MyCmd

That does the trick

Bergsy

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

Re: Getting livecode to execute a statement contained in a s

Post by Klaus » Tue Jul 01, 2014 10:57 am

Hi bergsy,

1. welcome to the forum! :D

2. In your example script there is no need to DO something:
...
put "btnContinue" into myBtn
put "Continue to next screen" into myToolTip
set the ToolTip of btn myBtn to myToolTip
## Does the trick!
...
8)


Best

Klaus

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

Re: Getting livecode to execute a statement contained in a s

Post by dunbarx » Tue Jul 01, 2014 3:06 pm

What Klaus said. No need to "do" what might already be doable.

But you touched on a larger issue. When you simply said "myCmd", this would have worked if you already had a handler by that name. That line is considered by LC as a message to be sent up the hierarchy. Since there was no such handler with that name, you got an error.

So if you are a warrior, you will correct that situation with your original script, and write back with your results. This is a central and powerful technique that you simply must know how to use.

Waiting...

Craig Newman

bergsy
Posts: 45
Joined: Mon Oct 28, 2013 10:51 pm

Re: Getting livecode to execute a statement contained in a s

Post by bergsy » Fri Mar 13, 2015 7:27 am

Craig, Klaus,

Sorry for the late reply. This issue became less of a priority in the last 6 months but will ramp up again soon

Your suggestions are appreciated

Cheers

Greg

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

Re: Getting livecode to execute a statement contained in a s

Post by Klaus » Fri Mar 13, 2015 1:17 pm

Hi Greg,

we didn't hold our breath! :D


Best

Klaus

Post Reply