**Feature Request**
`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`lappend` to convert and ''handle'' into a ''number'' and return the ''number'' to an ''external'' ressource
****Old Code****
======
# 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`
**Sol*Feature Requestion***
please add an `-index` option to `lappend` just to return the ''index'' of the new created element and '''not''' the whole list.
****New Code****
======
# factory startup (constructor)
constructor {{tmpl ""}} {
next $tmpl
my ConfigSetServerSetup serverSetup
}
method LcConfigC_WriteHDL { hdl } {
my variable LcConfigC_Handle
lappend -index LcConfigC_Handle $hdl
}
======
****add-on****
multiple arguments to `lappend -index` should return a ''list-of-indexes''
======
set hdlLst {a b c}
lappend -index hdlLst d e f
> 3 4 5
======
possible but '''not''' beautiful solution with '''single''' `lappend` without using `LcConfigC_Idx`,
======
method LcConfigC_WriteHDL { hdl } {
my variable LcConfigC_Handle
lappend LcConfigC_Handle $hdl
expr {[llength $LcConfigC_Handle]-1}
}
======