On the subject of things with the same short name... ('identical' groups which behave differently)

Sean Cole (Pi) sean at pidigital.co.uk
Fri Oct 8 10:49:10 EDT 2021


Hi David,

It seems confusing and I see how. Me and This are really useful and
powerful keywords. And that is the point in this example. 'The rect of me'
uses it as a keyword referring to itself. It knows then not to look any
further and applies it to itself. But once you add 'the long name of' the
compiler looks at it as a variable. It's as if you had 'put the long name
of me into tVar ; put the rect of tVar'.

The difference between this and me become evident the most for me when i
use something like:

on openStack

if the short name of me is the short name of this stack then

-- Do the openStack process for the stack this script is in, and not for
others

end if

end openStack

Meaning you can have a script run for the current top-most stack using
'this stack' while having it written in the script for another stack, 'me'.

'me' is also useful in behaviors as it refers, not to the behavior button
you put it in but, to the object/control that called the behavior. Livecode
rocks in this type of scripting!

Sean


On Fri, 8 Oct 2021 at 12:16, David V Glasgow via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Ah! (light comes on).  Thanks Sean.  So ‘me’ is actually more specific
> than it would seem!  I avoided ‘me' because it returns the short name of an
> object (of which there are several), and went for the long name of me
> because it is unique.
>
> Just to be clear, what you are saying is that when LC searches for ‘me’,
> the first one found will always be the target, and the search stops there.
>
> I still don’t understand why rect (the rect of the long name of me) works
> in one but fails in another group, though.
>
> Cheers,
>
> David G
>
> > On 8 Oct 2021, at 10:58 am, Sean Cole (Pi) via use-livecode <
> use-livecode at lists.runrev.com> wrote:
> >
> > The message path looks for the first instance it finds with a given name.
> > As your script is within the group itself, it would be easier (lazier ;)
> )
> > to reference to each group as 'me'
> > eg
> > lock screen for visual effect in rect (the rect of me)
> >
> > rather than 'the rect of the long name of me'
> >
> > Sean
> >
> > On Fri, 8 Oct 2021 at 10:32, David Glasgow via use-livecode <
> > use-livecode at lists.runrev.com> wrote:
> >
> >> Being essentially a lazy and a sloppy programmer, I made a group which
> >> contained a script that caused the group to do what I wanted.  Then I
> >> copied it again and again, and grouped the resultant groups.   Rather
> than
> >> adapting the script to be located on the card I just left several
> identical
> >> scripts in groups which have the same short name.  I told you.  Lazy.
> >> However, all groups worked absolutely fine.
> >>
> >> I then decided to add a visual effect to the final unlock screen in each
> >> instance.  I tried a couple of groups to see how it would look, and I
> found
> >> that it worked perfectly on one group, but not a second, identical(?)
> >> group.
> >>
> >> The script is...
> >> +++++++++++
> >>
> >> on mouseup
> >>
> >> lock screen for visual effect in rect (the rect of the long name of me)
> >>
> >> **depending on target object which was clicked, change appearance of
> group
> >> here**
> >>
> >> unlock screen with visual wipe right slow
> >>
> >> end mouseup
> >>
> >> +++++++++++
> >>
> >> There are no other locks or unlocks.
> >>
> >> The weird thing is that the script runs without error in both cases.
> The
> >> final appearance of the group in both cases is exactly what I would
> >> expect.  However, the visual effect manifests itself in one instance,
> but
> >> not the other.  I was bit hesitant about 'the rect of the long name of
> me’,
> >> but as I keep saying, it seems to works perfectly in one case.
> >>
> >> Que pasa?
> >>
> >> (  Mac 10.13.6 and LC 9.6, if that makes a difference.)
> >>
> >> Best Wishes,
> >>
> >> David Glasgow
> >> Consultant Forensic & Clinical Psychologist
> >> Carlton Glasgow Partnership
> >> Director, Child & Family Training, York
> >> Honorary Professor, Nottingham Trent University (SOCAMRU)
> >>
> >>
> >> _______________________________________________
> >> 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