Extracting a reference to a stack

David Bovill david at viral.academy
Sat Aug 8 20:43:50 EDT 2015


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 <ambassador at fourthworld.com>
wrote:

> 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 stack of rubbish" - but even then it
> wouldn't break since the long ID of the object would be:
>
>   button id 1003 of card id 1002 of stack "this is of stack of rubbish"
>   of stack "/Users/t/Desktop/stack.livecode"
>
> ...in which the first occurrence of " of stack " is the one we want.
>
> We could break it by changing the use case: instead of requiring long IDs
> (I rarely anything else) we might pass in a long name, in which a button
> might have a name that includes " of stack ".
>
> But as soon as we allow other forms of object references to be passed in
> we're probably going to want to convert those to long IDs anyway.  And
> since we can't guarantee the object reference is valid we'd probably need
> to add a try structure there as well:
>
> function ObjectStack pObj
>    try
>      put the long id of pObj into pObj
>    catch tErr
>      throw "Error in call to ObjectStack: invalid object reference"
>    end try
>    return char (offset(" of stack ", pObj)+4) to -1 of pObj
> end ObjectStack
>
> Any other edge cases that should be accounted for?
>
> --
>  Richard Gaskin
>  Fourth World Systems
>  Software Design and Development for the Desktop, Mobile, and the Web
>  ____________________________________________________________________
>  Ambassador at FourthWorld.com                http://www.FourthWorld.com
>
> _______________________________________________
> 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