Duplicate Control IDs
claudi.c at fiberworld.nl
Tue Oct 25 05:01:53 CDT 2011
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"
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...
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
> Anyone ever come across this before?
> 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:
More information about the use-livecode