Version 0 of Automatically generate Bwise blocks from procedures

Updated 2003-11-21 02:08:06

by {Theo Verelst]

I've recently made interactive command composer, which contains rudimentary, but working routines to take the list of procedures from the bwise procs_window generated dialog window, and extends it with the possiblity to automatically list a (double) clicked procedures' arguments, which can be (double) clicked to be added to an editable list of argument-value pairs, from which with one button-push, an executable command can be generated.

On the bottom of that page, I've examplified a routine to generate a block on the bwise canvas based on a procedure, for which a further version is presented here.

The procedures on this page make little sense without the bwise package loaded first. See Bwise page for pointer to latest (one file, txt or tcl extension, prepend https:// for secure download) version which can be downloaded from the tclhttpd server I run, and distributed linked bwise for a list of bwise pages.

You'll either need to edit (a copy of) the bwise source file, to make sure the 'procs_window' procedure isn't called before the new one on this page is sourced, or use destroy .f to get rid of the old procedure window. The latter can (as I did) also be done from a script which automatically loads the standard bwise source file, destroys the .f window, loads the new stuff, calls procs_window again, and resizes some fonts when desired.

 # Generate a unique name for a bwise block with given basename
 # It checks for existing number-extended blocks, and generates 
 # an incremented number
 proc block_genname { {blockname {a}} } {
   set l {};
 # find all basic block rectangles (third tag = block), find out the name (by the first tag)
 # and list those names
   foreach i [tag_and {block}] {lappend l "[block_name_fromid $i]"}
 # find all blocks starting with given name, and sort results
   set b [lsort -int -dict -decr [lsearch -all $l $blockname*]]
 # get names from sorted indices
   set m {};
   foreach i $b {lappend m [lindex $l $i]}
 #puts $b,$m
 # when one or more existing block with same basename exists
   if {$m != {}} {
 # extract highest extension
       set mm [string range [lindex $m 0] [string length $blockname] end]
 #puts $mm
 # if non-existing yet, but basename exists, extend with 1
      if {$mm == {}} {set mm 0}
      incr mm
      set blockname "$blockname$mm"
   }
   return $blockname
 } 



http://195.241.128.75/Bwise/procwindow2.jpg http://195.241.128.75/Bwise/procwindow3.jpg