Re: Extracting a reference to a stack

2015-08-14 Thread Bob Sneidar
I do the same thing, except mine isn't a one liner. (Show off!) Bob S > On Aug 8, 2015, at 15:51 , Richard Gaskin wrote: > > dunbarx wrote: > >> Wait just a doggone minute. The long id of a control contains the stack >> reference. > > Yep - and being a lazy person this is how I get the stac

Re: Extracting a reference to a stack

2015-08-09 Thread Peter Haworth
I guess how you approach this is a matter of coding preferences. All the solutions posted work but some of them have certain edge cases when they won't, most of which I've run into at one time or another. I still prefer using the engine's knowledge of the ownership hierarchy of an object since it

Re: Extracting a reference to a stack

2015-08-09 Thread Mike Bonner
Ah thats too bad. I guess the other idea could still work. Dispatch a message to the object in question. Change getprop to.. command owningstack return the name of this stack end owningstack To get at the information just dispatch "owningstack" to myLongId put the result I have a feature requ

Re: Extracting a reference to a stack

2015-08-09 Thread Richard Gaskin
Mike Bonner wrote: Ok. Better way. Use a virtual getprop in a library stack getprop owningstack return (the name of this stack) end owningstack Then if you have the long id of an object you can do this.. get the owningstack of myLongId and "it" will contain the stackname. (should also work

Re: Extracting a reference to a stack

2015-08-09 Thread Peter M. Brigham
Yes, it does work. My error. You don't even have to use the long id, you can use something like get the owningStack of btn "help" of stack "myStack" and as long as stack "myStack" is open it works. Of course, if you have enough info to specify the stack, then you already know the name of the s

Re: Extracting a reference to a stack

2015-08-09 Thread Mike Bonner
Hmm. It works fine for me.. Since you're "getting" the property for the object itself, the reference is based on that object. IE get the owningstack of -- the long id being used sets the scope starting at the object in question, so that when it references "the name of this stack" its relative to

Re: Extracting a reference to a stack

2015-08-09 Thread Peter M. Brigham
Clever. But since the long id of the object is not used by the getprop handler, this always returns the name of the topstack, so it can't be used for more general situations, eg, if you want to get the owningstack of a control on a stack that is suspended. -- Peter Peter M. Brigham pmb...@gmai

Re: Extracting a reference to a stack

2015-08-08 Thread Mike Bonner
Ok. Better way. Use a virtual getprop in a library stack getprop owningstack return (the name of this stack) end owningstack Then if you have the long id of an object you can do this.. get the owningstack of myLongId and "it" will contain the stackname. (should also work inserted into front,

Re: Extracting a reference to a stack

2015-08-08 Thread Mike Bonner
This may not do things in the required way, but.. If you have a library stack with a function or command that just grabs the name of "this stack" then you can dispatch or send the request to the object and POOF it'll tell you what stack its on, no parsing necessary. Just tried it here, and it wor

Re: Extracting a reference to a stack

2015-08-08 Thread Richard Gaskin
David Bovill wrote: > Yes - you're right. The long name is the only case and like you I > only use long ids in the use cases I have. Except when I store > references when I use the ruggedID handler of the IDE - that should > be a native reference I think? It would be nice to have an engine versi

Re: Extracting a reference to a stack

2015-08-08 Thread David Bovill
Yes - you're right. The long name is the only case and like you I only use long ids in the use cases I have. Except when I store references when I use the ruggedID handler of the IDE - that should be a native reference I think? On Sunday, August 9, 2015, Richard Gaskin wrote: > David Bovill wrot

Re: Extracting a reference to a stack

2015-08-08 Thread Richard Gaskin
David Bovill wrote: > Richard Gaskin wrote: > >> function ObjectStack pObj > >>return char (offset(" of stack ", pObj)+4) to -1 of pObj > >> end ObjectStack > > The test case would be "this is a stack of rubish" as a substack - > that would break your code? It would have to be "this is a of

Re: Extracting a reference to a stack

2015-08-08 Thread David Bovill
The test case would be "this is a stack of rubish" as a substack - that would break your code? On 9 August 2015 at 00:59, Richard Gaskin wrote: > Thierry Douez wrote: > > >> Yep - and being a lazy person this is how I get the stack reference: > >> > >> function ObjectStack pObj > >>return ch

Re: Extracting a reference to a stack

2015-08-08 Thread Richard Gaskin
Thierry Douez wrote: >> Yep - and being a lazy person this is how I get the stack reference: >> >> function ObjectStack pObj >>return char (offset(" of stack ", pObj)+4) to -1 of pObj >> end ObjectStack > > Not always beneficial to be lazy :) > > I tried your code with the long ID I gave prev

Re: Extracting a reference to a stack

2015-08-08 Thread J. Landman Gay
On 8/8/2015 6:20 PM, David Bovill wrote: the new offset feature (which I think is the feature I remember). The offset feature hasn't changed, but you may be thinking of the itemDelimiter, which in LC 7 can be more than one character. -- Jacqueline Landman Gay | jac...@hyperactive

Re: Extracting a reference to a stack

2015-08-08 Thread Thierry Douez
> Yep - and being a lazy person this is how I get the stack reference: > > function ObjectStack pObj >return char (offset(" of stack ", pObj)+4) to -1 of pObj > end ObjectStack > Not always beneficial to be lazy :) I tried your code with the long ID I gave previously without success. Regards

Re: Extracting a reference to a stack

2015-08-08 Thread David Bovill
Wow - lot's of cool examples. Richards is one of the shortest - but breaks theoretically if a stack is named weirdly. Thierry gets the nerdy award, and mark for digging up the new offset feature (which I think is the feature I remember). By the way one of the most puzzling aspects of software conv

Re: Extracting a reference to a stack

2015-08-08 Thread Richard Gaskin
dunbarx wrote: Wait just a doggone minute. The long id of a control contains the stack reference. Yep - and being a lazy person this is how I get the stack reference: function ObjectStack pObj return char (offset(" of stack ", pObj)+4) to -1 of pObj end ObjectStack -- Richard Gaskin Fo

Re: Extracting a reference to a stack

2015-08-08 Thread Thierry Douez
Here is a regex solution. and as a bonus, in 3 variants: on mouseUp --button id 1003 of card id 1002 of stack "stack 2" --of stack "/Users/t/Desktop/stack.livecode" put fld "L1" into aLongID put theStackOwner( aLongID) into field "L2" put theMainStackOwne

Re: Extracting a reference to a stack

2015-08-08 Thread Peter M. Brigham
On Aug 8, 2015, at 1:45 PM, Peter Haworth wrote: > I do it like this > > function stackOfObject pobject > > local tObject > > put pobject into tObject > repeat > if word 1 of tObject is "stack" then > return tObject > end if I assume you meant to include a line "delete word 1 of tObject

Re: Extracting a reference to a stack

2015-08-08 Thread Peter Haworth
Whoops, hit send too soon, should be: function stackOfObject pobject repeat if word 1 of pobject is "stack" then return pobject else put the long owner of pobject into pobject end repeat end stackOfObject On Sat, Aug 8, 2015 at 10:45 AM Peter Haworth wrote: > I

Re: Extracting a reference to a stack

2015-08-08 Thread Peter Haworth
I do it like this function stackOfObject pobject local tObject put pobject into tObject repeat if word 1 of tObject is "stack" then return tObject end if On Sat, Aug 8, 2015 at 10:31 AM Peter M. Brigham wrote: > OK, Here's a revision: > > function ownerStack pObjLongID >-- return

Re: Extracting a reference to a stack

2015-08-08 Thread Peter M. Brigham
OK, Here's a revision: function ownerStack pObjLongID -- returns the name of the stack immediately containing pObjLongID -- by Peter M. Brigham, pmb...@gmail.com — freeware -- tags: control -- requires getprop robustName replace " of " with cr in pObjLongID put lineoffset(cr

Re: Extracting a reference to a stack

2015-08-08 Thread Mark Wieder
On 08/08/2015 07:45 AM, David Bovill wrote: There was a recent feature added to the language that would help - maybe it was something to do with the owner I LC7 you can now set whole words as delimiters. So (off the top of my head) set the itemDelimiter to "stack" get item -1 of the long i

Re: Extracting a reference to a stack

2015-08-08 Thread David Bovill
There was a recent feature added to the language that would help - maybe it was something to do with the owner I have a similarly convoluted function and getprop - one of the issues is that if you want the long name of the stack the control is part of - this could be a mainstack or a substack

Re: Extracting a reference to a stack

2015-08-08 Thread Peter M. Brigham
Here's a quick solution: function ownerStack pObjLongID replace " of " with numtochar(8) in pObjLongID set the itemdel to numtochar(8) return item -1 of pObjLongID end ownerStack A more general solution is what I use in my library. The getItem() function is so useful that I use it *ever

Re: Extracting a reference to a stack

2015-08-08 Thread dunbarx
Wait just a doggone minute. The long id of a control contains the stack reference. Craig -Original Message- From: David Bovill To: How to use LiveCode Sent: Sat, Aug 8, 2015 8:24 am Subject: Extracting a reference to a stack Given the long id of a control - how do I extract the

Re: Extracting a reference to a stack

2015-08-08 Thread dunbarx
- From: David Bovill To: How to use LiveCode Sent: Sat, Aug 8, 2015 8:24 am Subject: Extracting a reference to a stack Given the long id of a control - how do I extract the reference to the stack ti belongs to? I have a function that i have used since the dawn of time for this - but I recall se

Extracting a reference to a stack

2015-08-08 Thread David Bovill
Given the long id of a control - how do I extract the reference to the stack ti belongs to? I have a function that i have used since the dawn of time for this - but I recall seeing a new chunk / target / reference feature of Livecode in the last year that makes this easier. Did I imagine it? __