Shaun Kulesa <
[email protected]> wrote:
Thank you for your suggestions, I tried using struct tree but the documentation is not very helpful.
How can I rename the root node to ./docs
From the man page:
[1] The root node of the tree can be used in most places
where a node is asked for. The default name of the
rootnode is "root", but this can be changed with the
method re‐ name (see below). Whatever the current name
for the root node of the tree is, it can be retrieved by
calling the method rootname.
Testing the manpage directions:
$ rlwrap tclsh
% package require struct::tree
2.1.2
% struct::tree tree
::tree
% tree rootname
root
% tree rename root ./docs
./docs
% tree rootname
./docs
%
and when I walk the tree what should the -command argument and script
look like?
There is no "-command" option in struct::tree. And there are two walk sub-commands, 'walk' and 'walkproc'. Walk takes a script as argument,
so not a 'command', so you likely are using 'walkproc' (which takes a
command prefix). From the docs:
treeName walkproc node ?-order order? ?-type type? cmdprefix
This method is like method walk in all essentials, except
the interface to the user code. This method invokes a
command prefix with three additional arguments (tree,
node, and action), instead of evaluating a script and
passing the node via a loop variable.
The prefix is invoked with three extra arguments added by the tree
object: tree, node, action.
So your command needs, at a minimum, three arguments:
proc tree-callback {tree node action} { ... }
And you'd call it by doing:
tree walkproc root tree-callback
If you want to pass in additional data, add those arguments before the
three that the tree object adds:
proc tree-callback {extra1 extra2 tree node action} { ... }
And call like so:
tree walkproc root [list tree-callback $extra_data_1 $extra_data_2]
Assuming the 'extra' data was in those two variables. Adjust to fit
your usage.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)