Hi Russell,
<p>
You are correct that it only accepts even number of element lists. list_to_multirow also suffers from this behaviour. I have now corrected it on the latest ver. Although it requires you to pass in the colnames for this. No colnames is kinda like {{element val} {element val}}. I think.
<p>
Dan,
<p>
I have revise my code to follow the same behaviour of list_to_multirow when no colnames are passed. Here is a snip code:
<pre>
set mylist [list [list a b] [list d e]]
template::util::list_to_multirow multi1 $mylist
hw_essay::list_of_lists_to_multirow -varname multi2 -listoflists $mylist
hw_essay::list_of_lists_to_multirow -varname multi3 -listoflists $mylist -colnames [list col1 col2]
set test ""
for { set i 1 } { $i <= ${multi1:rowcount}} { incr i } {
append test "multi1 = [array get multi1:$i] multi2 = [array get multi2:$i] multi3 =[array get multi3:$i]"
}
</pre>
<p>
The out put will be
<pre>
multi1 = rownum 1 a b
multi2 = rownum 1 a b
multi3 =rownum 1 col2 b col1 a
------------------------------------------------------
multi1 = rownum 2 d e
multi2 = rownum 2 d e
multi3 =rownum 2 col2 e col1 d
</pre>
<p>
Looks similar. Although list_to_multirow suffers from a bug as pointed by Russell. So "set mylist [list [list a b c] [list d e f]]" will give an error. Using "hw_essay::list_of_lists_to_multirow -varname multi3 -listoflists $mylist -colnames [list col1 col2 col3]" things will be ok.
<p>
I will leave the decision to you about the code: if its good enough to be at template util procs. If it will patch list_to_multirow. If it will be an additional proc. If it will depracate list_to_multirow.
<p>
Here is the latest
<a href="/sdm/one-patch.tcl?patch_id=352">code</a>. Please see if there are bugs, I am bit busy right now so no big test was done on it.