Top 1
invalid command name "toplevel"
    while executing
"toplevel $wtop"
    (procedure "RasmolCreateWidget" line 11)
    invoked from within
"RasmolCreateWidget $rootw $id $asTop"
    (procedure "RasmolCreate" line 7)
    invoked from within
"RasmolCreate .mol 1"
    (in namespace eval "::request" script line 268)
    invoked from within
"namespace eval ::request $script"
    ("::try" body line 12)

OUTPUT BUFFER:

set RasmolVar(counter) 0 proc RasmolInit { id } { global RasmolVar set RasmolVar($id,return) 0 set RasmolVar($id,prompt) "rasmol$id> " set RasmolVar($id,promptLen) [string length [set RasmolVar($id,prompt)]] } proc RasmolEcho { id line } { global RasmolVar set wtxt [set RasmolVar($id,wtxt)] if { [set RasmolVar($id,return)] } { $wtxt insert end "\n" } $wtxt insert end "${line}\n" $wtxt see end set RasmolVar($id,return) 0 } proc RasmolInterpret { id line } { global RasmolVar puts "RasmolInterpret $id $line" switch -regexp $line { puts ">$line" ^IPC { RasmolEcho $id [string range $line 4 end] } {^[ ]*exit} {} ^RasMol> { puts "RasMol"} ^Atom: { puts "Atom" scan $line "Atom: %s %d Group: %s %d Chain: %s" \ atName atNb resName resNb chain puts "Picked : $atName $atNb $resName $resNb $chain" catch {eval [set RasmolVar($id,pickFct)] {$line}} RasmolEcho $id $line } default { puts "default"; RasmolEcho $id $line } } } proc RasmolDumpOut { id } { global RasmolVar set count [gets [set RasmolVar($id,rasOut)] rasline] if { $count < 0 } { RasmolCmdPrompt $id } else { RasmolInterpret $id $rasline } } proc RasmolDoCmd {id cmd {silent 2}} { global RasmolVar # puts "In RasmolDoCmd $id [set RasmolVar($id,interp)] :$cmd: $silent" send [set RasmolVar($id,interp)] $cmd set wtxt [set RasmolVar($id,wtxt)] switch -exact $silent { 1 { $wtxt insert end $cmd $wtxt insert end "\n" RasmolCmdPrompt $id } 2 { $wtxt insert end "\n" RasmolCmdPrompt $id } default { } } } proc RasmolAnyKey { id char} { global RasmolVar set RasmolVar($id,rtn) 0 if {$char != " "} { } else { # puts "apres2 :[set RasmolVar($id,cmd)]:[set RasmolVar($id,curr)]:" } } proc RasmolRtnKey { id } { global RasmolVar set wtxt [set RasmolVar($id,wtxt)] set start [$wtxt index "end - 1 lines \ linestart + [set RasmolVar($id,promptLen)] chars"] set end [$wtxt index "end - 1 lines lineend"] set cmd [$wtxt get $start $end] RasmolDoCmd $id $cmd } # The procedure below is used to print out a prompt at the # insertion point (which should be at the beginning of a line # right now). proc RasmolCmdPrompt { id } { global app RasmolVar set RasmolVar($id,return) 1 set wtxt [set RasmolVar($id,wtxt)] $wtxt mark set {insert} "end" $wtxt insert insert "[set RasmolVar($id,prompt)]" $wtxt mark set promptEnd {insert} $wtxt mark gravity promptEnd left $wtxt tag add bold {promptEnd linestart} promptEnd $wtxt see end } proc RasmolCreateBinding { id } { global RasmolVar set wtxt [set RasmolVar($id,wtxt)] bind $wtxt "RasmolRtnKey $id" # unactivate the Text class binding bind Text { } # bind $wtxt "RasmolAnyKey $id %A" bind $wtxt "focus $wtxt" bind $wtxt { } # Create a binding to forward commands to the target application, # plus modify many of the built-in bindings so that only information # in the current command can be deleted (can still set the cursor # earlier in the text and select and insert; just can't delete). puts "bindtags [bindtags $wtxt]" #default is : .mol0.text Text .mol0 all bindtags $wtxt "$wtxt Text" bind $wtxt { catch {$wtxt tag remove sel sel.first promptEnd} if {[$wtxt tag nextrange sel 1.0 end] == ""} { if [$wtxt compare insert < promptEnd] { break } } } bind $wtxt { catch {$wtxt tag remove sel sel.first promptEnd} if {[$wtxt tag nextrange sel 1.0 end] == ""} { if [$wtxt compare insert <= promptEnd] { break } } } bind $wtxt { if [$wtxt compare insert < promptEnd] { break } } bind $wtxt { if [$wtxt compare insert < promptEnd] { $wtxt mark set insert promptEnd } } bind $wtxt { if [$wtxt compare insert < promptEnd] { break } } bind $wtxt { if [$wtxt compare insert < promptEnd] { break } } bind $wtxt { if [$wtxt compare insert <= promptEnd] { break } } bind $wtxt { if [$wtxt compare insert <= promptEnd] { break } } } proc RasmolCreateWidget { w id asTop} { global RasmolVar global tcl_platform global env #wm title . "rascmd" set wtop $w$id if { $asTop } { puts "Top $asTop" catch {destroy $wtop } toplevel $wtop } else { puts "not Top $asTop" frame $wtop } set wtxt $wtop.text set wscroll $wtop.scroll set RasmolVar($id,wtxt) $wtxt text $wtxt -height 25 -width 80 -yscrollcommand "$wscroll set" scrollbar $wscroll -command "$wtxt yview" # pack .rascom -fill both -side left -expand 1 pack $wtxt -fill both -side left -expand 1 pack $wscroll -side left -fill y RasmolCreateBinding $id $wtxt tag configure bold -font {Courier 12 bold} set OldInterp [winfo interps] if {$tcl_platform(platform) eq "windows"} { set rexe [file join $env(ProgramFiles) ordali bin raswin.exe] regsub "Program Files" $rexe "PROGRA~1" rexe eval set RasmolVar($id,rasOut) [open "|$rexe " r] } else { set RasmolVar($id,rasOut) [open "| rasmol " r] } set i 0 if {0} { while {[set NewInterp [winfo interps]] == $OldInterp } { update incr i if { $i > 500 } { puts "Problems to create rasmol process" puts "NewInterp : $NewInterp" puts "OldInterp : $OldInterp" exit 1 } } } set RasmolVar($id,interp) "RasWin System" set RasmolVar(id,RasWin) $id set RasmolVar($id,prompt) "rasmol> " set RasmolVar($id,promptLen) [string length [set RasmolVar($id,prompt)]] fconfigure [set RasmolVar($id,rasOut)] -blocking false -buffering line fileevent [set RasmolVar($id,rasOut)] readable "RasmolDumpOut $id" rasmol_cmd $id } proc rasmol_cmd { id } { set cmd { "set menus false" \ "set display selected" \ "load ant1.pdb" \ "select none" \ "select *.P" \ "label %n%r" } foreach c $cmd { RasmolDoCmd $id $c 0 } } proc pickFct { line } { puts "pickFct :$line:" } proc RasmolCreate { rootw asTop {pickFunction {}}} { global RasmolVar set id $RasmolVar(counter) RasmolInit $id set RasmolVar($id,pickFct) $pickFunction RasmolCreateWidget $rootw $id $asTop incr RasmolVar(counter) return $id } RasmolCreate .mol 1