Lingo alt to adding code to an object at runtime

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: FourthWorld, heatherlaine, Klaus, robinmiller

Post Reply
CenturyMan1979
Posts: 86
Joined: Tue May 15, 2012 5:56 pm
Location: Minneapolis, MN

Lingo alt to adding code to an object at runtime

Post by CenturyMan1979 » Tue May 15, 2012 6:11 pm

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?

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

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

Post by monte » Tue May 15, 2012 11:27 pm

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
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

CenturyMan1979
Posts: 86
Joined: Tue May 15, 2012 5:56 pm
Location: Minneapolis, MN

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

Post by CenturyMan1979 » Wed May 16, 2012 2:50 am

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

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

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

Post by Klaus » Wed May 16, 2012 10:14 am

Shall I delete this thread?

Post Reply

Return to “Converting to LiveCode”