View Single Post
Old 15th February 2020, 07:25 PM   #7
Tomkat
Member
Expert member
 
Join Date: Nov 2010
Posts: 79
Default Re: Auto Save to Time

I have no idea how to write scripts... but I was able to figure out how to change the posted script into an "auto save" that just overwrites the open file every 5 minutes.

Code:
namespace eval asave {
    # Autosave implementation
    
    proc auto_save {ms} {
        # if a model is loaded, save version, repeat after ms millisec
        
        global unsaved_changes
        global acfilename ;# last saved file name
        if {$unsaved_changes} {
            set orname $acfilename
            set fname [file root $acfilename].ac
            menu_save_last
            set acfilename $orname
        }
        after $ms "eval asave::auto_save $ms"
    }
    asave::auto_save 300000 ;# 60000 = 1 minute.
    # puts "Autosave start"
}
Tomkat is offline   Reply With Quote