lappend is a wonderful command to append to a tcl-list. The problem is to get the index of the last insert.
I Use this to convert and handle into a number and return the number to an external ressource
# factory startup (constructor) constructor {{tmpl ""}} { next $tmpl my ConfigSetServerSetup serverSetup my variable LcConfigC_Idx set LcConfigC_Idx -1 } method LcConfigC_WriteHDL { hdl } { my variable LcConfigC_Handle LcConfigC_Idx lappend LcConfigC_Handle $hdl incr LcConfigC_Idx }
As you see to return the index it is required to maintain a second variable (in my case LcConfigC_Idx) and init the second variable in the constructor to -1
please add an -index option to lappend just to return the index of the new created element and not the whole list.
# factory startup (constructor) constructor {{tmpl ""}} { next $tmpl my ConfigSetServerSetup serverSetup } method LcConfigC_WriteHDL { hdl } { my variable LcConfigC_Handle lappend -index LcConfigC_Handle $hdl }