Page 1 of 1

Lingo alt to adding code to an object at runtime

Posted: Tue May 15, 2012 6:11 pm
by CenturyMan1979
Was looking for a little help on how I can add code to a dynamically created object in livecode. In Lingo I could do the following to add an object then add code to it.



What would a script look like to do this in livecode if it is possible?

Re: Lingo alt to adding code to an object at runtime

Posted: Tue May 15, 2012 11:27 pm
by monte
Hi

There's a few ways to tackle this:

Livecode has script setting limits as a form of copy protection so you can only use this if your script is under 10 lines:
Set the script of myObject to myScript

An alternative is to create a template control with the script and all other properties set already then:
Clone myTemplateObject
Set the name of it to myObjectName

A better alternative is to use a behavior script so that you can maintain the code in one place. Create a button somewhere with the script you want and then:
Set the behavior of myObject to the long id of myBehavior

Cheers

Monte

Re: Lingo alt to adding code to an object at runtime

Posted: Wed May 16, 2012 2:50 am
by CenturyMan1979
Thanks for the reply. Also this post was made by accident. Here is a link to the correct posting.

http://forums.runrev.com/viewtopic.php?f=32&t=11970

Re: Lingo alt to adding code to an object at runtime

Posted: Wed May 16, 2012 10:14 am
by Klaus
Shall I delete this thread?