next up previous contents index
Next: Remote Control of VMD Up: Tips and Tricks Previous: Finding Contact Residues

Tcl Logging

 

Every issued command which changes the state of VMD (loading a molecule, rotation, opening a form, etc.) can be saved to a file via the log command. In addition, if the Tcl command vmdlog exists, it is called with the issued command as its only term. One use for this is to filter out some of the commands.

One practical use of this feature is to filter out the menu commands so they don't constantly disappear and reappear on playback. In addition, this adds wait command if the time between succesive commands was more than a second so the playback will emulate the timings of original actions.

        # set things up to record commands to the file ``session_log.vmd''
        proc start_recording {} {
             global recording_fileid 
             set recording_fileid [open session_log.vmd w]
        }
             
        # set up the vmdlog proc
             
	proc vmdlog s {
	     if {[regexp {^menu } $s] != 1} {
                 global recording_fileid
                 global recording_time
                 set now [getclock]
                 set delay [expr $now - $recording_time]
                 if {$delay > 1} {
                   puts $recording_fileid "wait $delay"
                 }
                 puts $recording_fileid $s
                 flush $recording_fileid
                 set recording_time $now
             }
        }
        
        proc stop_recording {} {
             global recording_fileid
             unset recording_fileid -1
             rename vmdlog {}
        }



Justin Gullingsrud
Tue Apr 6 09:22:39 CDT 1999