• tablelist and unknow

    From Manfred Stelzhammer@manfred@antispam.at to comp.lang.tcl on Sat Oct 5 19:24:38 2024
    From Newsgroup: comp.lang.tcl

    Hi

    If I create a tablelist widget with "-movablecolumns 1" an I'll move a
    column it works ok.

    But if I have a proc "unknown" I cann't move a column.

    ##

    proc unknown {args} {puts "unknown : $args"}

    ##

    If I move in the tablelistwidget a column I get:

    % unknown : moveCol .tbl 2 1

    But the position from the column don't change.

    How can I solve the problem?

    regards

    Manfred




    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Manfred Stelzhammer@manfred@antispam.at to comp.lang.tcl on Sat Oct 5 19:32:18 2024
    From Newsgroup: comp.lang.tcl

    Hi

    I found a workaround.

    I create a proc moveCol.

    ##
    proc moveCol {args} {::tablelist::moveCol {*}$args}
    ##

    regards

    Manfred


    Am 05.10.24 um 19:24 schrieb Manfred Stelzhammer:
    Hi

    If I create a tablelist widget with "-movablecolumns 1" an I'll move a column it works ok.

    But if I have a proc "unknown" I cann't move a column.

    ##

    proc unknown {args} {puts "unknown : $args"}

    ##

    If I move in the tablelistwidget a column I get:

        % unknown : moveCol .tbl 2 1

    But the position from the column don't change.

    How can I solve the problem?

    regards

    Manfred





    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Manfred Stelzhammer@manfred@antispam.at to comp.lang.tcl on Sat Oct 5 20:45:38 2024
    From Newsgroup: comp.lang.tcl

    Sorry, I'm wrong, the workaround does'nt work.

    regards

    Manfred

    Am 05.10.24 um 19:32 schrieb Manfred Stelzhammer:
    Hi

    I found a workaround.

    I create a proc moveCol.

    ##
    proc moveCol {args} {::tablelist::moveCol {*}$args}
    ##

    regards

    Manfred


    Am 05.10.24 um 19:24 schrieb Manfred Stelzhammer:
    Hi

    If I create a tablelist widget with "-movablecolumns 1" an I'll move a
    column it works ok.

    But if I have a proc "unknown" I cann't move a column.

    ##

    proc unknown {args} {puts "unknown : $args"}

    ##

    If I move in the tablelistwidget a column I get:

         % unknown : moveCol .tbl 2 1

    But the position from the column don't change.

    How can I solve the problem?

    regards

    Manfred






    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From clt.to.davebr@clt.to.davebr@dfgh.net to comp.lang.tcl on Sun Oct 6 02:54:54 2024
    From Newsgroup: comp.lang.tcl


    Subject: tablelist and unknow

    If I create a tablelist widget with "-movablecolumns 1" an I'll move a >column it works ok.

    But if I have a proc "unknown" I cann't move a column.

    ##

    proc unknown {args} {puts "unknown : $args"}

    Your unknown command might be masking an auto-loaded command or package.

    See the Tcl unknown manpage for more information.

    daveb

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From nemethi@csaba.nemethi@t-online.de to comp.lang.tcl on Sun Oct 6 12:34:08 2024
    From Newsgroup: comp.lang.tcl

    Am 05.10.24 um 20:45 schrieb Manfred Stelzhammer:
    Sorry, I'm wrong, the workaround does'nt work.

    regards

    Manfred

    Am 05.10.24 um 19:32 schrieb Manfred Stelzhammer:
    Hi

    I found a workaround.

    I create a proc moveCol.

    ##
    proc moveCol {args} {::tablelist::moveCol {*}$args}
    ##

    regards

    Manfred


    Am 05.10.24 um 19:24 schrieb Manfred Stelzhammer:
    Hi

    If I create a tablelist widget with "-movablecolumns 1" an I'll move
    a column it works ok.

    But if I have a proc "unknown" I cann't move a column.

    ##

    proc unknown {args} {puts "unknown : $args"}

    ##

    If I move in the tablelistwidget a column I get:

         % unknown : moveCol .tbl 2 1

    But the position from the column don't change.

    How can I solve the problem?

    regards

    Manfred







    1. As pointed out by daveb, it is dangerous to override the default
    unknown proc. In addition, your unknown proc just prints its arguments, which, of course, won't change the position of any column.

    2. Your "workaround" that uses a proc moveCol:

    proc moveCol {args} { ::tablelist::moveCol {*}$args }

    works for me as expected. For example,

    moveCol .tbl 2 1

    does move column 2 before column 1.

    3. The above works, but it uses the ::tablelist::moveCol proc, which
    belongs to the implementation of the tablelist widget, not to its
    documented, public API. It is much better to use something like

    proc moveCol {args} {
    lassign $args tbl sourceCol targetCol
    $tbl movecolumn $sourceCol $targetCol
    }
    --
    Csaba Nemethi https://www.nemethi.de mailto:csaba.nemethi@t-online.de
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From clt.to.davebr@clt.to.davebr@dfgh.net to comp.lang.tcl on Sun Oct 6 12:32:21 2024
    From Newsgroup: comp.lang.tcl

    From: nemethi <csaba.nemethi@t-online.de>

    3. The above works, but it uses the ::tablelist::moveCol proc, which
    belongs to the implementation of the tablelist widget, not to its >documented, public API. It is much better to use something like

    proc moveCol {args} {
    lassign $args tbl sourceCol targetCol
    $tbl movecolumn $sourceCol $targetCol
    }


    I'm curious why you suggest using lassign $args... instead of putting the variables in the proc arguments list? Something like:

    proc moveCol {tbl sourceCol targetCol} {$tbl movecolumn $sourceCol $targetCol}

    Do error messages make more sense that way, or is it more efficient?

    daveb

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From nemethi@csaba.nemethi@t-online.de to comp.lang.tcl on Sun Oct 6 17:51:08 2024
    From Newsgroup: comp.lang.tcl

    Am 06.10.24 um 14:32 schrieb clt.to.davebr@dfgh.net:
    From: nemethi <csaba.nemethi@t-online.de>

    3. The above works, but it uses the ::tablelist::moveCol proc, which
    belongs to the implementation of the tablelist widget, not to its
    documented, public API. It is much better to use something like

    proc moveCol {args} {
    lassign $args tbl sourceCol targetCol
    $tbl movecolumn $sourceCol $targetCol
    }


    I'm curious why you suggest using lassign $args... instead of putting the variables in the proc arguments list? Something like:

    proc moveCol {tbl sourceCol targetCol} {$tbl movecolumn $sourceCol $targetCol}

    Do error messages make more sense that way, or is it more efficient?

    daveb


    The only reason for using args was that the OP used this form with both
    procs unknown and moveCol.
    --
    Csaba Nemethi https://www.nemethi.de mailto:csaba.nemethi@t-online.de
    --- Synchronet 3.20a-Linux NewsLink 1.114