Re: Object naming

2020-07-28 Thread Jerry Jensen via use-livecode
Dave’s not here.
https://www.youtube.com/watch?v=rtDAK7Umk7A

> On Jul 27, 2020, at 10:24 PM, Richard Gaskin via use-livecode 
>  wrote:
> 
> Consider a simplified problem statement:
> 
> You have two objects of the same type in a container, and you want to tell 
> them apart but had given them the same name.
> 
> 
> 
>   Too Many Daves
>   by Dr. Seuss
> 
>   Did I ever tell you that Mrs. McCave
>   Had twenty-three sons and she named them all Dave?
>   Well, she did. And that wasn't a smart thing to do.
>   You see, when she wants one and calls out, "Yoo-Hoo!
>   Come into the house, Dave!" she doesn't get one.
>   All twenty-three Daves of hers come on the run!
>   This makes things quite difficult at the McCaves'
>   As you can imagine, with so many Daves.
>   And often she wishes that, when they were born,
>   She had named one of them Bodkin Van Horn
>   And one of them Hoos-Foos. And one of them Snimm.
>   And one of them Hot-Shot. And one Sunny Jim.
>   And one of them Shadrack. And one of them Blinkey.
>   And one of them Stuffy. And one of them Stinkey.
>   Another one Putt-Putt. Another one Moon Face.
>   Another one Marvin O'Gravel Balloon Face.
>   And one of them Ziggy. And one Soggy Muff.
>   One Buffalo Bill. And one Biffalo Buff.
>   And one of them Sneepy. And one Weepy Weed.
>   And one Paris Garters. And one Harris Tweed.
>   And one of them Sir Michael Carmichael Zutt
>   And one of them Oliver Boliver Butt
>   And one of them Zanzibar Buck-Buck McFate ...
>   But she didn't do it. And now it's too late.
> 
> --
> Richard Gaskin
> Fourth World Systems
> 
> 
>> Alex Tweedly alex at tweedly.net
>> Mon Jul 27 15:47:12 EDT 2020
>>Previous message (by thread): Object naming
>>Next message (by thread): Object naming
>>Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>> On 27/07/2020 16:33, Richard Gaskin via use-livecode wrote:
>>> There are many ways to refer to things.  The simplest is to use unambiguous 
>>> names for things that matter.
>>> 
>> Is there an unambiguous name in this case ? And if so, what is it :-) ?
>> A group "A" contains a rectangle "R", and a (sub)group "B". "B" also 
>> contains a rectangle "R". (btw - "B" also may contain a subgroup "C", and it 
>> too will have a rectangle "R", and ).
>> There is an unambiguous name for the 'most nested' "R", but there doesn't 
>> seem to be for the other "R"s. I had expected (or perhaps just hoped) that 
>> using a long name would first try to find an exact match, and if that failed 
>> it would then find the closest inexact match - but that sadly was just a 
>> hope.
>> I could (and probably will) use IDs but that doesn't work for duplicating 
>> the group - you need to either go in and adjust a script / custom property 
>> OR have the group's script find the IDs.
>> Or - am I'm missing something ?
>> Alex.
> 
> 
> ___
> use-livecode mailing list
> use-livecode@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Object naming

2020-07-28 Thread Martin Koob via use-livecode
From Kids in the Hall

https://www.youtube.com/watch?v=8nvzEqsZIGo

Martin


> On Jul 28, 2020, at 2:32 PM, Jim Lambert via use-livecode 
>  wrote:
> 
> Zanzibar Buck-Buck McFate was my lawyer.
> One day I asked if I could call him Zanz.
> He said, “Nah. Just call me Dave!”
> 
> Jim Lambert
> 
> 
> ___
> use-livecode mailing list
> use-livecode@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Object naming

2020-07-28 Thread Jim Lambert via use-livecode
Zanzibar Buck-Buck McFate was my lawyer.
One day I asked if I could call him Zanz.
He said, “Nah. Just call me Dave!”

Jim Lambert


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Object naming

2020-07-28 Thread Alex Tweedly via use-livecode



On 28/07/2020 08:27, Curry Kenworthy via use-livecode wrote:


Alex:

> Using unambiguous short names prevents behaviour scripts
> that references child controls completely

Sure about that? (Option A)

Yes, I think I am. At least, it prevents using names of the child 
objects in the script. The other solution using cached IDs works in a 
behaviour script. But I still can't see a way to do it using names.


Give me one more clue please; I'd really like to use option A.


> Inside A, there is a rect called "R" and also a group called "B"
> inside B there is a rect called "R"

Or put the "direct" R in a subgroup also. (Option B)
A-B-R vs A-C-R.

No, unfortunately option B doesn't work. Remember that A and B are 
instances of the same group, so when you introduce the extra group level 
in A, you do the same in B; i.e. it's now A-C-R versus A-B-C-R


And again Livecode's "incomplete" name matching will give whichever one 
has a lower layer number.


Verified:
> *put*thelongnameofgrc"R1"ofgrp"A"
... graphic "R1" of group "C" of group "B" of group "A" of card id 1002 
of stack "Untitled 1"


when A-B is lower than A-C (which it has to be to avoid obscuring it).


So I'm going to abandon this idea - I can go back to a different 
solution which allows behaviour scripts, but requires slightly more 
setup. Not quite so easy to use (initially), but probably easier to 
continue to use in the long run.


Many thanks,

Alex.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Object naming

2020-07-28 Thread Alex Tweedly via use-livecode
Thanks Martin. That does indeed work (might need tweaking for some more 
complex cases).


However, it goes through all controls on the card - the same effect is 
achieved without the performance risk using the childControlIDs, as in



function idOfChild pLongID, pShortName
  repeat for each line L in the childControlIDs of  pLongID
 if the short name of control ID L = pShortName then return the 
long id of control ID L

  end repeat
end idOfChild

I'm currently using that - but I'm convinced by Richard and Dr Seuss 
that I'm on the wrong path and will try a redesign.


Alex.

On 28/07/2020 04:04, Martin Koob wrote:

Hi Alex

You could use the owner of the control in conjunction with the name of 
the control to distinguish between the two graphic’s named ‘R’.


I did that  for the  simple case in your example  but may not work 
with something more complex.


I created a stack with the same hierarchy of graphics and groups and 
using the following scripts in a button I placed on the card I can 
distinguish between  graphic A - R and B - R.


*
*

*on* mouseup

*ask*“enter owner name/control name/control colour"

*put* it into tResponse

*set*theitemdelimiterto"/"

*put*item1of tResponse into tOwner

*put*item2of tResponse into tControl

*put*item3of tResponse into tControlColour

*put* findTargetControl(tOwner, tControl) into tTargetControl

*set*thebackgroundcolorofcontrol tTargetControl 
of*group*"A"to tControlColour


*end* mouseup


*function* findTargetControl pOwner, pControl

*put*thenumberofcontrolsof*group*"A"into tIndex

*repeat* with tControl = 1to tIndex

*if* theshortnameofcontrol tControl of*group*"A" = pControl *then*

*if* theshortnameoftheownerofcontrol tControl of*group*"A" = pOwner *then*

*exit* *repeat*

*end* *if*

*end* *if*

*end* *repeat*

*return* tControl

*end* findTargetControl


Martin Koob



On Jul 27, 2020, at 8:47 PM, Alex Tweedly via use-livecode 
> wrote:



On 27/07/2020 21:26, Curry Kenworthy via use-livecode wrote:


Use unambiguous SHORT names!


Thanks, but ...

Yes, using unambiguous SHORT names solves this naming problem, but 
introduces other problems. In particular, this group script should 
(probably) be a behaviour script, since the group will be 
instantiated multiple times and will in the future need updating for 
enhancements or even (Heaven forfend!) bug fixes.


Using unambiguous short names prevents behaviour scripts that 
references child controls completely, and even if I simply used 
normal scripts which were replicated for each instance, I'd still 
need to go through the script to change all the references to the 
child control names (a pain, and source of possible future errors).


For now, I'm caching the IDs of the direct child controls in 
script-local variables in each instance of the group. If I find a 
name-based way that works reliably and allows behaviour scripts, I'll 
change - but this method works.


I'll have this group ready for release soon (or soon-ish) so y'all'll 
be able to see how it turned out :-)


Thanks again everyone,

Alex.


___
use-livecode mailing list
use-livecode@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Object naming

2020-07-28 Thread Alex Tweedly via use-livecode



On 28/07/2020 06:24, Richard Gaskin via use-livecode wrote:

Consider a simplified problem statement:

You have two objects of the same type in a container, and you want to 
tell them apart but had given them the same name.



+100

OK, when I stop laughing, I will admit I am convinced :-)

Alex.


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Object naming

2020-07-28 Thread Richmond via use-livecode

You are asking for trouble.

Think about something as goofy and as simple as this:

Inside A1, there is a rect called "R1" and also a group called "B1"
inside B1 there is a rect called "R2" . . .

Am I missing something?

Richmond.

On 28.07.20 10:27, Curry Kenworthy via use-livecode wrote:


Alex:

> Using unambiguous short names prevents behaviour scripts
> that references child controls completely

Sure about that? (Option A)

> Inside A, there is a rect called "R" and also a group called "B"
> inside B there is a rect called "R"

Or put the "direct" R in a subgroup also. (Option B)
A-B-R vs A-C-R.

Richard:

> One Buffalo Bill. And one Biffalo Buff.

I like that one.

Best wishes,

Curry Kenworthy

Custom Software Development
"Better Methods, Better Results"
LiveCode Training and Consulting
http://livecodeconsulting.com/


___
use-livecode mailing list
use-livecode@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Object naming

2020-07-28 Thread scott--- via use-livecode
So Alex, the takeaway here seems to be that once you name your child objects… 
“now it’s too late.”

While reading this out aloud, I taught my classes of 2nd and 3rd graders to 
say, “Noo” after the second line. And I usually paused to let the class 
finish Oliver Boliver’s name.

—
Scott Morrow

Elementary Software
(Now with 20% less chalk dust!)
web   https://elementarysoftware.com/
--



> On Jul 27, 2020, at 10:24 PM, Richard Gaskin via use-livecode 
>  wrote:
> 
> Consider a simplified problem statement:
> 
> You have two objects of the same type in a container, and you want to tell 
> them apart but had given them the same name.
> 
> 
> 
>   Too Many Daves
>   by Dr. Seuss
> 
>   Did I ever tell you that Mrs. McCave
>   Had twenty-three sons and she named them all Dave?
>   Well, she did. And that wasn't a smart thing to do.
>   You see, when she wants one and calls out, "Yoo-Hoo!
>   Come into the house, Dave!" she doesn't get one.
>   All twenty-three Daves of hers come on the run!
>   This makes things quite difficult at the McCaves'
>   As you can imagine, with so many Daves.
>   And often she wishes that, when they were born,
>   She had named one of them Bodkin Van Horn
>   And one of them Hoos-Foos. And one of them Snimm.
>   And one of them Hot-Shot. And one Sunny Jim.
>   And one of them Shadrack. And one of them Blinkey.
>   And one of them Stuffy. And one of them Stinkey.
>   Another one Putt-Putt. Another one Moon Face.
>   Another one Marvin O'Gravel Balloon Face.
>   And one of them Ziggy. And one Soggy Muff.
>   One Buffalo Bill. And one Biffalo Buff.
>   And one of them Sneepy. And one Weepy Weed.
>   And one Paris Garters. And one Harris Tweed.
>   And one of them Sir Michael Carmichael Zutt
>   And one of them Oliver Boliver Butt
>   And one of them Zanzibar Buck-Buck McFate ...
>   But she didn't do it. And now it's too late.
> 
> --
> Richard Gaskin
> Fourth World Systems
> 
> 
>> Alex Tweedly alex at tweedly.net
>> Mon Jul 27 15:47:12 EDT 2020
>>Previous message (by thread): Object naming
>>Next message (by thread): Object naming
>>Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>> On 27/07/2020 16:33, Richard Gaskin via use-livecode wrote:
>>> There are many ways to refer to things.  The simplest is to use unambiguous 
>>> names for things that matter.
>>> 
>> Is there an unambiguous name in this case ? And if so, what is it :-) ?
>> A group "A" contains a rectangle "R", and a (sub)group "B". "B" also 
>> contains a rectangle "R". (btw - "B" also may contain a subgroup "C", and it 
>> too will have a rectangle "R", and ).
>> There is an unambiguous name for the 'most nested' "R", but there doesn't 
>> seem to be for the other "R"s. I had expected (or perhaps just hoped) that 
>> using a long name would first try to find an exact match, and if that failed 
>> it would then find the closest inexact match - but that sadly was just a 
>> hope.
>> I could (and probably will) use IDs but that doesn't work for duplicating 
>> the group - you need to either go in and adjust a script / custom property 
>> OR have the group's script find the IDs.
>> Or - am I'm missing something ?
>> Alex.
> 
> 
> ___
> use-livecode mailing list
> use-livecode@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Object naming

2020-07-28 Thread Curry Kenworthy via use-livecode



Alex:

> Using unambiguous short names prevents behaviour scripts
> that references child controls completely

Sure about that? (Option A)

> Inside A, there is a rect called "R" and also a group called "B"
> inside B there is a rect called "R"

Or put the "direct" R in a subgroup also. (Option B)
A-B-R vs A-C-R.

Richard:

> One Buffalo Bill. And one Biffalo Buff.

I like that one.

Best wishes,

Curry Kenworthy

Custom Software Development
"Better Methods, Better Results"
LiveCode Training and Consulting
http://livecodeconsulting.com/


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Object naming

2020-07-28 Thread JB via use-livecode
That is really cool, Richard!
JB

Sent from my iPad

> On Jul 27, 2020, at 10:26 PM, Richard Gaskin via use-livecode 
>  wrote:
> 
> Consider a simplified problem statement:
> 
> You have two objects of the same type in a container, and you want to tell 
> them apart but had given them the same name.
> 
> 
> 
>   Too Many Daves
>   by Dr. Seuss
> 
>   Did I ever tell you that Mrs. McCave
>   Had twenty-three sons and she named them all Dave?
>   Well, she did. And that wasn't a smart thing to do.
>   You see, when she wants one and calls out, "Yoo-Hoo!
>   Come into the house, Dave!" she doesn't get one.
>   All twenty-three Daves of hers come on the run!
>   This makes things quite difficult at the McCaves'
>   As you can imagine, with so many Daves.
>   And often she wishes that, when they were born,
>   She had named one of them Bodkin Van Horn
>   And one of them Hoos-Foos. And one of them Snimm.
>   And one of them Hot-Shot. And one Sunny Jim.
>   And one of them Shadrack. And one of them Blinkey.
>   And one of them Stuffy. And one of them Stinkey.
>   Another one Putt-Putt. Another one Moon Face.
>   Another one Marvin O'Gravel Balloon Face.
>   And one of them Ziggy. And one Soggy Muff.
>   One Buffalo Bill. And one Biffalo Buff.
>   And one of them Sneepy. And one Weepy Weed.
>   And one Paris Garters. And one Harris Tweed.
>   And one of them Sir Michael Carmichael Zutt
>   And one of them Oliver Boliver Butt
>   And one of them Zanzibar Buck-Buck McFate ...
>   But she didn't do it. And now it's too late.
> 
> --
> Richard Gaskin
> Fourth World Systems
> 
> 
>> Alex Tweedly alex at tweedly.net
>> Mon Jul 27 15:47:12 EDT 2020
>>Previous message (by thread): Object naming
>>Next message (by thread): Object naming
>>Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>>> On 27/07/2020 16:33, Richard Gaskin via use-livecode wrote:
>>> There are many ways to refer to things.  The simplest is to use unambiguous 
>>> names for things that matter.
>>> 
>> Is there an unambiguous name in this case ? And if so, what is it :-) ?
>> A group "A" contains a rectangle "R", and a (sub)group "B". "B" also 
>> contains a rectangle "R". (btw - "B" also may contain a subgroup "C", and it 
>> too will have a rectangle "R", and ).
>> There is an unambiguous name for the 'most nested' "R", but there doesn't 
>> seem to be for the other "R"s. I had expected (or perhaps just hoped) that 
>> using a long name would first try to find an exact match, and if that failed 
>> it would then find the closest inexact match - but that sadly was just a 
>> hope.
>> I could (and probably will) use IDs but that doesn't work for duplicating 
>> the group - you need to either go in and adjust a script / custom property 
>> OR have the group's script find the IDs.
>> Or - am I'm missing something ?
>> Alex.
> 
> 
> ___
> use-livecode mailing list
> use-livecode@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode