The Long Name peculiarities

Peter M. Brigham pmbrig at gmail.com
Tue Jun 19 08:47:19 EDT 2012


On Jun 18, 2012, at 8:21 PM, Peter Haworth wrote:

> Thanks Mike, interesting what happens if you just click in and out of the
> name box.  Unfortunately, I don't have control over the objects that cause
> this behavior - they are part of the datagrid structure.
> 
> I think I will report it as a bug.  Kind of a pain to work around it
> though.  I think I will have to have a repeat loop that gets the name of
> the owner, then the owner of the owner, etc, until I get to a group that is
> a datagrid or the card.  Easy enough to script, just a hassle to have to do
> it for this special case.

As a work-around, here's a handler that I use from time to time, and it could be modified for your purpose:

<script>

getProp robustID
   ----  a virtual property, read only  ----
   -- getting the long id of a control can result in different values depending on
   -- (a) where the stack is stored on the user's disk and
   -- (b) which card is the currentcard when the function is called
   -- the robustID is consistent no matter what card is current
   -- and no matter which folder the user has stored the stack in;
   -- format: button id 1039 of bkgnd id 1003 of stack "subStack1"
   --            of stack "tMainStack"
   -- robustID can be used as a full object reference, just like long ID
   
   -- requires q()
   
   put numtochar(6) into delim1
   put numtochar(7) into delim2
   put the long id of the target into tLongID
   replace " stack " with delim1 in tLongID
   set the itemdelimiter to delim1
   put item -1 of tLongID into mainStackFileName
   if not (word 1 of mainStackFileName = "stack") then
      put "stack " before mainStackFileName
   end if
   put the short name of mainStackFileName into mainStackName
   if word 1 of tLongID = "stack" then
      put q(mainStackName) into word 2 of tLongID
   else
      put q(mainStackName) into item -1 of tLongID
   end if
   replace delim1 with " stack " in tLongID
   replace " of " with delim2 in tLongID
   set the itemdelimiter to delim2
   put itemoffset("card",tLongID) into cdItemNbr
   if cdItemNbr > 1 then delete item cdItemNbr of tLongID
   replace delim2 with " of " in tLongID
   replace "group" with "bkgnd" in tLongID
   -- in case the group is not placed on the currentcard
   return tLongID
end robustID

function q str
   -- quote
   return quote & str & quote
end q

</script>

Try 
   put the long name of the target into tLongID
instead of
   put the long id of the target into tLongID
in the beginning of the script. This seems to work for me. If it does what you want, you'll probably want to rename the handler "robustName" (and change the name of the variable to "tLongName" to avoid confusing yourself later).

-- Peter

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

   
> On Mon, Jun 18, 2012 at 4:01 PM, Mike Bonner <bonnmike at gmail.com> wrote:
> 
>> If you go into the inspector after creating the 2 grcs the name is set to
>> the id. I think this is a behavior that occurs when there is no valid name
>> set for the grc, but the name of the grc isn't actually whats shown in the
>> inspector. If you click in the box, don't change the name, click out of the
>> box, things start to work. (and it would make sense.  No name available, so
>> it defaults to showing the id of things instead)
>> 
>> Still think its a bug though, shouldn't there be a valid default name that
>> is set when using 'create grc' ?
>> 
>> On Mon, Jun 18, 2012 at 4:46 PM, Bob Sneidar <bobs at twft.com> wrote:
>> 
>>> Wow! Nice catch! If not a bug, it's certainly an "anomaly".
>>> 
>>> Bob
>>> 
>>> 
>>> On Jun 18, 2012, at 3:32 PM, Peter Haworth wrote:
>>> 
>>>> I've come across what I think is a bug in what is returned as the long
>>> name
>>>> of a control.  It only happens in fairly obscure circumstances.
>>>> 
>>>> Here's the recipe (LC 5.5).
>>>> 
>>>> Button script:
>>>> 
>>>> on mouseUp
>>>> create graphic
>>>> create graphic
>>>> end mouseUp
>>>> 
>>>> Group the two graphics together and give the group a specific name, eg
>>>> "Groupa", instead of it's default name
>>>> 
>>>> Give one of the two graphics a specific name, eg "grc1", instead of its
>>>> default name
>>>> 
>>>> Select the named graphic and in the message box, do "put the long name
>> of
>>>> selobj()"  You will get:
>>>> 
>>>> graphic "grc1" of group "GroupA" of ….
>>>> 
>>>> Now select the other, unnamed graphic and repeat the message box
>> command.
>>>> You will get
>>>> 
>>>> graphic id 123 of group 456 of……
>>>> 
>>>> In other words, if a control is unnamed, the long name returns the ids
>> of
>>>> it's owner(s), not their names.
>>>> 
>>>> Some of my scripts are failing because of this because I am looking for
>>>> certain group names in a control's long name
>>>> 
>>>> To me, this is a bug but I've been corrected before on what I believe
>> to
>>> be
>>>> bugs so what do you think?
>>>> _______________________________________________
>>>> 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
>>> 
>> _______________________________________________
>> 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