finding the name of the target's stack in a script
Peter Haworth
pete at lcsql.com
Wed Jul 25 03:16:14 EDT 2012
I'm guessing almost everyone on this list have their own routines to do
this and it's interesting to see the different methods. Here's mine, with
a getOwner thrown in for good measure.
function getGroup pid
if word 1 of the owner of pid is not "group" then
return empty
else
return the short name of the owner of pid
end if
end getGroup
function getCard pid,preturn
if word 1 of the abbrev name of the owner of pid is "card" then
if preturn is "name" then
return the short name of the owner of pid
else
return the long ID of the owner of pID
end if
else
return getCard(the long ID of the owner of pid)
end if
end getCard
function getOwner pid
put getGroup(pid) into pgroup
if pgroup is not empty then
return the abbrev name of pgroup
else
return getCard(pid)
end if
end getOwner
function getStack pid
return the name of the owner of getCard(pid,"long")
end getStack
Pete
lcSQL Software <http://www.lcsql.com>
On Tue, Jul 24, 2012 at 7:43 PM, Peter M. Brigham <pmbrig at gmail.com> wrote:
> On Jul 24, 2012, at 8:28 PM, Dr. Hawkins wrote:
>
> > It seems, though, that there should be a construct along the lines of
> >
> > the stack of <object>
> > the card of <object>
> > the group of <objec>
>
> I tried to find a way of doing this without "do" commands, but…
>
> function stackOf tObjLongID
> replace " of " with numtochar(8) in tObjLongID
> set the itemdelimiter to numtochar(8)
> put item -1 of tObjLongID into tStack
> do "put the short name of " && tStack && "into stackName"
> return stackName
> end stackOf
>
> function cardOf tObjLongID
> replace " of " with numtochar(8) in tObjLongID
> set the itemdelimiter to numtochar(8)
> put item -2 to -1 of tObjLongID into tCard
> replace numtochar(8) with " of " in tCard
> do "put the short name of" && tCard && "into cdName"
> return cdName
> end cardOf
>
> function groupOf tObjLongID
> if " group " is not in tObjLongID then return empty
> replace " of " with numtochar(8) in tObjLongID
> set the itemdelimiter to numtochar(8)
> put item -3 to -1 of tObjLongID into tGp
> replace numtochar(8) with " of " in tGp
> do "put the short name of" && tGp && "into gpName"
> return gpName
> end groupOf
>
> Can't do "stack of…" but you can do "stackOf(tLongID)"
>
> -- Peter
>
> Peter M. Brigham
> pmbrig at gmail.com
> http://home.comcast.net/~pmbrig
>
>
> _______________________________________________
> 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