Set the Behavior Not Working

Roger Guay irog at mac.com
Mon Aug 31 18:21:03 EDT 2015


That works! Thanks, Peter.


> On Aug 31, 2015, at 3:08 PM, Peter Haworth <pete at lcsql.com> wrote:
> 
> The behavior is just a string of text so I think you need quotes around the
> behavior:
> 
> set the behavior of the image to "button id 1721 of stack" & quote &
> "myCoolGameStack" & quote
> 
> I set the behavior to the long id of the button, just because  I don;t have
> write the clumsy code to put quotes around the stack name.
> 
> On Mon, Aug 31, 2015 at 3:02 PM Roger Guay <irog at mac.com> wrote:
> 
>> I think I understand your point here, Richard, except the association with
>> your last sentence. I thought the long id would insure the use of a
>> behavior of buttons outside the host stack. Put here is the thing:
>> 
>> I successfully used this:
>> 
>>        "set the behavior of last image to the long id of button
>> “myCoolBehavior" of card  “Main””
>> 
>> (card “main” is in myCoolSameStack stack)
>> 
>> When I use the message box for the behavior of that image, I get:
>> 
>>        "button id 1721 of stack “myCoolSameStack””
>> 
>> why then can I not script:
>> 
>>        “set the behavior of the image to button id 1721 of stack
>> “myCoolSameStack"?
>> 
>> 
>> Thanks,
>> 
>> Roger
>> 
>> 
>> 
>> 
>> 
>>> On Aug 31, 2015, at 12:49 PM, Richard Gaskin <ambassador at fourthworld.com>
>> wrote:
>>> 
>>> Remember that in LiveCode objects are often containers, allowing us to
>> do things like:
>>> 
>>> put field 1 into field 2
>>> 
>>> This works with button contents, and image contents as well - try this
>> in the Message Box:
>>> 
>>> put image 1
>>> 
>>> You should see the binary image data in the Message Box, since that's
>> the value contained in that control.
>>> 
>>> Buttons can contain data as well.  When the button is used as a menu
>> this data is the list of menu items, but any button can have data stored in
>> it - try this on a standard push button:
>>> 
>>>  put "Something" into btn 1; put btn 1
>>> 
>>> The "set the behavior" command expects a *reference* to an object, but
>> usually can't understand the *contents* of an object.
>>> 
>>> So it may be helpful to think of your line as:
>>> 
>>>  set the behavior of image id 1727 to \
>>>    (button id 1721 of stack “mySillyStack”)
>>> 
>>> ...which obtains the text of the button, if any, and then attempts to
>> set the image's behavior property to that value.  If we had used the button
>> we created in the above example as our object, your script line would be
>> interpreted as:
>>> 
>>>  set the behavior of image id 1727 to "Something"
>>> 
>>> ...which of course can only confuse an otherwise-reasonably-smart
>> LiveCode engine.
>>> 
>>> So as a general rule, having a habit of using the long id of an object
>> will give you a reliable *reference* to an object whenever's a reference is
>> needed, such as in the behavior property.
>>> 
>>> --
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list