Updated 2011-12-16 12:40:27 by RLE

Theo Verelst

Please feel free to add/comment prefbl. with some id... Oh, and eh, especially when it concerns the code...

Quite some time ago, I did this and some other, see also procs_window routine to simpy save all non-system procedures from a tcl/wish session. Basically because at the time I often sat down to develop that way, which has survived as a humane enough way to omitted-program something together which workds sensibly enough. I know, in the time I learned basic I had to un-learn such practices and learn the decent, hard, structured way. But heh, what have we learnt since then? Nasi schneider diagrams, functional programming, lambda functions, university stuff, and in the end? Some people do vbasic, others are quite organized ordering lists, and probably at least feel better about it.

So when some experiment has left you with a bunch of new routines, and you don't remember all their names, and your history and your scrollable window leave you without your precious work, use this one:
 proc save_procs { {n} } {
   global nnn
   set nnn $n
   uplevel #0 {
      set ooo {}
      foreach i [lsort -dict [info procs]] {
         if {[lsearch $defaultprocs $i] == -1 &&
                 [string index $i 0] != "\$"  &&
                 ![string match tcl* $i] &&
                                 ![string match tk* $i] } {
 #              eval set ttt $\{$i\}
 #              set uuu "set \{$i\} \{$ttt\} \n"
 #              eval set uuu {}
              #append ooo "set " $ttt " " $uuu \n
              append ooo "proc $i { "
              foreach a [info args $i] {
                  set d ""
                  if {[info default $i $a d]} {set d " {$d}"}
                  append ooo "{$a $d} "
              append ooo " } {" [info body $i] "}\n\n"
      set f [open $nnn w];
      puts $f $ooo;
      close $f

And you're safe again at the procedure level.

I simply saves all procedures except the ones whose names start with tcl or tk, and the ones listed in the defaultprocs global variable.

Which can be appropriately set by starting another, fresh and unused tcl/wish session, load all the same packages, and using the set_defaultprocs procedure from the page mentioned above, or by hand list all procedures in some other way, and seve them to some file, and read them into the defaultprocs variable. Or send them.

I'm very sure, looking over the code, that a lot of things have been experimental and could be done otherwise, neater, or more geared at more recent tcl versions, but I tried it to save the whole bwise package after I added and updated some procedures, and that seems to work fine. It is also in that package.