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
____________________________________________________________________
ambassa...@fourthworld.com http://www.FourthWorld.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