Help: Id's can be completly unreliable

Monte Goulding monte at sweattechnologies.com
Wed Nov 10 19:15:24 EST 2010


> It's my understanding that object ID's inside a stack are maintained by the engine to ensure uniqueness. I would not mess with the ID's at all. I remember back in Hypercard that was a big no-no as well. 

Well, true up to a point. The stack id is equal to the id of the next created control. It doesn't quite work that way in the IDE because the drag and drop from the tools palette creates and deletes a graphic.
> 
> About the only use of ID's that I can see would be if you were programmatically renaming objects, and you wanted to reference the same object after the rename with something that didn't change. I know that Trevor uses the long id of a button to define the storage object for sqlYoga, because someone might rename the button and break their own code. But changing ID's is IMHO a bad practice. 

Setting the stack ID to a number below it's current ID is a risk and you are right it's bad practice (I was just trying to work out how you end up with an id of 0 and I still couldn't replicate it) but going the other way is the only way we have to manage icon libraries. For example, the IDE image library sets the templateStack's id to the highest id of all the other image libraries+1. This means that there won't be any image id duplicates (as long as nobody adds an image to an older library *bug*).

Cheers

Monte


More information about the use-livecode mailing list