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?
Lingo alt to adding code to an object at runtime
Moderators: FourthWorld, heatherlaine, Klaus, robinmiller
-
- Posts: 86
- Joined: Tue May 15, 2012 5:56 pm
- Location: Minneapolis, MN
Re: Lingo alt to adding code to an object at runtime
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
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
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
-
- Posts: 86
- Joined: Tue May 15, 2012 5:56 pm
- Location: Minneapolis, MN
Re: Lingo alt to adding code to an object at runtime
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
http://forums.runrev.com/viewtopic.php?f=32&t=11970
Re: Lingo alt to adding code to an object at runtime
Shall I delete this thread?