CustomProperties

Peter Brigham MD pmbrig at gmail.com
Fri May 6 11:51:34 EDT 2011


On May 5, 2011, at 8:37 PM, DunbarX at aol.com wrote:

> You can. You can even set a custom property to an entire stack.
> 
> 
> I use these all the time, they are incredibly powerful and convenient.
> 
> 
> But I do not understand what it means to set a property to an object, as opposed to a chunk of text (or maybe a video file?). So you can set the xxx of btn "b1" to btn "b2". And if you then get the xxx of btn "b1", you will get empty, unless you have made button "b2" into a container, and put some text into it. In that case you get that text back. But that is not the same thing as having the button itself as the contents of the property, is it?
> 
> 
> It is a disconnect between what I think of as a property, and what I think of as a container.
> 
> 
> Can't wait to see how this works; I have always wondered...
> 
> 
> Craig Newman

Apparently it's not possible. I pulled this out of the list archives:

--------------

Ian McKnight wrote:

>  On 30/03/07, Richard Gaskin <ambassador at fourthworld.com> wrote:
> 
>> You can store a stack file in a custom property, but I don't know of a way to 
>> store individual controls there.
>> 
>> You may find the copy command will do what you need quite handily, since it lets you specify a target for the copy:
>>     copy <obj> to <dest>
>> 
>>  e.g.:
>> 
>>     copy grp 1 of stack "TemplateParts" to this cd of stack "UserStack"
>> 
>> When using the "to" option with the copy command it doesn't affect the user's clipboard, making it really convenient for both you and your user.
> 
> Hi Richard
> 
> I tried your suggestion with
> 
> copy grp "mygroup" of this stack to the umycustomProp
> 
> and got a Script Compile error
> Error description: Function: missing '('
> 
> So I guess that controls can't be stored there.
> 
> Correct. As I'd written, I know of no way to 
> store controls in custom properties.
 
The copy command can be used by simply storing your groups in some other 
stack as a repository, copying them into the user's stack as needed.

------------

If you don't want to use a storage stack, which is really the easiest thing to do, you can approximate storing a control as a customprop with something like this:

put the properties of btn "myBtn" into btnProps
-- btnProps is an array of properties
set the storedBtn of stack "myStack" to btnProps

The, to reconstitute the control (I think of this as adding water to a freeze-dried stew and sticking in in the microwave...),

put the storedBtn of stack "myStack" into btnProps
create invisible button
set the properties of it to btnProps

(will also make the new button visible if the original was visible)

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig






More information about the use-livecode mailing list