Page 1 of 1

Getting livecode to execute a statement contained in a strin

Posted: Tue Jul 01, 2014 7:53 am
by bergsy
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

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

Posted: Tue Jul 01, 2014 8:04 am
by bergsy
Figured it out:

do MyCmd

That does the trick

Bergsy

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

Posted: Tue Jul 01, 2014 10:57 am
by Klaus
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

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

Posted: Tue Jul 01, 2014 3:06 pm
by dunbarx
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

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

Posted: Fri Mar 13, 2015 7:27 am
by bergsy
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

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

Posted: Fri Mar 13, 2015 1:17 pm
by Klaus
Hi Greg,

we didn't hold our breath! :D


Best

Klaus