New programmer here. I have been trying to run my script through Tk console through a VMD program which works when I copy it into tkconsole, however when I source/load my script into tkconsole, it only runs part of the script before stopping and gives me two issues.
The issue I am having are:
- it loads up molecules but does not visually display it in the VMD window
- it runs most of my script, but gets stuck at the put $total section and feeds me back invalid command name "put"
I am unsure if I have missed a step when sourcing scripts, however when manually pasting in the whole script it seems to work. Wondering if anyone has input. Please see the script below:
mol new ubiquitin.psf
mol new pulling.dcd
set sel [atomselect top "index 942 963"]
set x [measure bond {59 60} frame all]
set total 0
for {set i 0} {$i <100 } {incr i} {
puts "I inside first loop: $[measure bond {59 60} frame $i]"; set total [expr {$total + [measure bond {59 60} frame $i]}]
}
put $total
expr {$total/100}
As Donal commented, your script fails due to a typo:
put
instead ofputs
.The reason it works when run manually is because of a procedure called
unknown
. This procedure is called whenever the interpreter encounters an unknown command. It then tries different things to handle the command:All except the first point are only attempted in interactive mode. So, in that situation the last option kicks in and runs
puts
when you typeput
. However, when running a script, that doesn't happen and you get the error you mentioned.