Duplicate Control IDs

Claudi Cornaz claudi.c at fiberworld.nl
Tue Oct 25 06:01:53 EDT 2011

Hi Pete,

This has happened to me several times, with a couple of different stacks.
I put it already twice on this list. Last time was in november 2010.
I found a routine in the IDE with a comment about the engine returning a id of zero sometimes. 
I found the script it in the button "revIDE" of the revLibrary stack and it's called "addObject" 

private command addObject pObject, pObeyDontSearch, @rList, pScriptsOnly
  if word 1 of the name of pObject is among the words of "card group field" and pObeyDontSearch and the dontSearch of pObject then
     return "dontSearch set on object"
  end if

  local tId
  put the long id of pObject into tId
  if word 3 of tId is 0 then
     # Due to an engine bug, some objects can have IDs of zero. For now, we ignore this...
  end if

Unfortunatly I haven't been able to isolate the bug in a repeatable simple way.

Because of this bug I changed my programming habbits when cloning or copying controls to a grp.
First I get the number of controls in the grp. Then I do the copying and then reference the new control by number to set it's name so I can reference the control afterwards by long name like:
.....  ....
put the number of controls of grp "xxxx" into tCount
copy control "yyy" to grp "xxx"
set the name of control tCount of grp "xxx" to "myNewControl"

This way even if the conrol has a id of zero I can refence the control by long name.
It's a drag and defenitly should not happen. It has happened to me, and bite me, with versions of runrev 3.x and upwards.

The nasty bit I noticed was that using the it variable (which holds the long id of the newly created control) 
after the copying didn't produce a error when it contained the long id of a control with a id of zero.
It just screwed things up.

I sure hope, now somebody else got the same problem, this get's finaly solved.

All the best

On 24 okt 2011, at 19:45, Pete wrote:

> I have run into a weird situation that ends up with duplicate control IDs on
> a card which I thought couldn't happen.
> The scenario is that I copy a group containing two field controls from one
> stack to a group in another stack.  After copying, the two field controls
> both have an ID of zero!  Needless to say, this plays havoc with anything I
> do that tries to access the fields.
> I have worked around the problem by creating a new group, then copying the
> two fields individually from the source group to the new one and that works
> fine.
> Anyone ever come across this before?
> Pete
> Molly's Revenge <http://www.mollysrevenge.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