Changeset 466
- Timestamp:
- Dec 4, 2009 5:06:38 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expgui
- Property rcs:date changed from 2001/10/14 05:34:23 to 2001/10/18 23:22:57
- Property rcs:lines changed from +8 -6 to +40 -127
- Property rcs:rev changed from 1.48 to 1.49
r457 r466 242 242 global expgui expmap entryvar entrycmd tcl_platform 243 243 # is this a compressed archive file? 244 if {[string match {*.EXP.[0-9][0-9][0-9].gz} $expfile] && \ 245 $tcl_platform(platform) == "unix"} { 246 regexp {.*.EXP} $expfile rootname 247 if {[auto_execok gunzip] == ""} { 248 # tno gunzip -- bail out 249 MyMessageBox -parent . -title "Cannot Load Archived File" \ 250 -message "Unable to find the gunzip program in your path. Loading this archived version of [file tail $rootname] requires the gzip program. Load gunzip or fix your path and then restart EXPGUI" \ 251 -icon error 252 return 253 } 244 if {[string match {*.O[0-9A-F][0-9A-F]} $expfile]} { 245 set expgui(expfile) {} 246 set expnam [file rootname $expfile] 254 247 set ans [MyMessageBox -parent . -title "Load Archived File" \ 255 -message "Loading archived version of [file tail $rootname]. Do you want to overwrite $rootname or savethe archived version under a new name?" \256 -icon question -type "{Use New Name} Overwrite"\248 -message "Loading archived version of $expnam. Do you want to continue using the same experiment name or work with the archived version under a new name?" \ 249 -icon question -type "{Use New Name} {Continue with current}" \ 257 250 -default {Use New Name} \ 258 251 -helplink "expguierr.html LoadArchived" 259 252 ] 253 # archive the current .EXP file 254 if {$ans != "use new name" && [file exists $expfile]} { 255 # get the last archived version 256 set lastf [lindex [lsort [glob $expnam.{O\[0-9A-F\]\[0-9A-F\]}]] end] 257 if {$lastf == ""} { 258 set num 01 259 } else { 260 regexp {.*\.O([0-9A-F][0-9A-F])$} $lastf a num 261 scan $num %x num 262 if {$num >= 255} { 263 set num FF 264 } else { 265 set num [string toupper [format %.2x [incr num]]] 266 } 267 } 268 catch { 269 set newfile $expnam.O$num 270 file rename -force $expnam.EXP $newfile 271 exec echo "\n----------------------------------------------" >> $expnam.LST 272 exec echo " Regressing to archive file [file tail $expfile]" >> $expnam.LST 273 exec echo " but first archiving [file tail $expnam.EXP] as [file tail $newfile]" >> $expnam.LST 274 exec echo "----------------------------------------------\n" >> $expnam.LST 275 } 276 } 277 file copy -force $expfile $expnam.EXP 260 278 set fmt [expload $expfile] 279 # if the file was not in the correct format, force a rewrite before use 261 280 if {$fmt < 0} { 262 281 # read error 263 282 return 264 } 265 set expgui(changed) 1 266 set expfile $rootname 267 if {$ans == "use new name"} { 268 SaveAsFile 269 set expfile $expgui(expfile) 270 } 271 # is this an uncompressed archive file? 272 } elseif {[string match {*.EXP.[0-9][0-9][0-9]} $expfile] && \ 273 $tcl_platform(platform) == "unix"} { 274 regexp {.*.EXP} $expfile rootname 275 set ans [MyMessageBox -parent . -title "Load Archived File" \ 276 -message "Loading archived version of [file tail $rootname]. Do you want to overwrite $rootname or save the archived version under a new name?" \ 277 -icon question -type "{Use New Name} Overwrite"\ 278 -default {Use New Name} \ 279 -helplink "expguierr.html LoadArchived" 280 ] 281 set fmt [expload $expfile] 282 if {$fmt < 0} { 283 # read error 284 return 285 } 286 set expgui(changed) 1 287 set expfile $rootname 283 } elseif {$fmt == 1} { 284 set expgui(changed) 0 285 } else { 286 set expgui(changed) 1 287 } 288 set expfile $expnam.EXP 288 289 if {$ans == "use new name"} { 289 290 SaveAsFile … … 426 427 if $expgui(changed) { 427 428 set decision [tk_dialog .instrSaveData {Save .EXP changes} \ 428 {You have made changes to the Experiment. Reading a different file wi ll cause the changes to be lost. Select an option:} \429 {You have made changes to the Experiment. Reading a different file without first saving will cause the changes to be lost. Select an option:} \ 429 430 {} 0 "Save and read" "Read without Save" "Cancel read command"] 430 431 switch $decision { … … 570 571 return 571 572 } 573 if {![file exists $expgui(expfile)]} { 574 after 2000 afterawhile 575 return 576 } 572 577 if {[file mtime $expgui(expfile)] != $expgui(expModifiedLast)} { 573 578 # we are "locked". Note that whenidle loop will be restarted later … … 710 715 2 { return "Cancel" } 711 716 } 712 }713 714 proc archiveexp {} {715 global expgui tcl_platform716 # is there a file to archive717 if {![file exists $expgui(expfile)]} return718 catch {719 set expnam [file rootname $expgui(expfile)]720 if {$tcl_platform(platform) == "windows"} {721 set version -1722 catch {source $expnam.version}723 incr version724 if ![file executable [file join $expgui(scriptdir) pkzip.exe]] {725 # archive w/o pkzip726 set file $expnam![format "%3.3d" $version].EXP727 file copy -force $expnam.EXP $file728 set fp [open $expnam.lst a]729 puts $fp "\n--------------------------------------------------------------"730 puts $fp "Archiving $expnam.EXP as $file"731 puts $fp "--------------------------------------------------------------\n"732 close $fp733 } else {734 # archive with PKZIP735 # need to limit expnam to 8 characters736 set sexp [string toupper [string range [file root [file tail $expnam] ] 0 7]]737 # PKZIP can't handle long dir names either738 cd [set dir [file dirname $expnam]]739 set file $sexp.[format "%3.3d" $version]740 file copy -force $expnam.EXP $file741 exec [file join $expgui(scriptdir) pkzip.exe] -m $sexp $file > zip.out &742 set fp [open $expnam.lst a]743 puts $fp "\n--------------------------------------------------------------"744 puts $fp "Archiving $expnam.EXP as $file in [file join $dir $sexp.ZIP]"745 puts $fp "--------------------------------------------------------------\n"746 close $fp747 }748 set fp [open $expnam.version w]749 puts $fp "set version $version"750 close $fp751 } else {752 set files [glob -nocomplain $expnam.EXP.*]753 if {$files == ""} {754 set file $expnam.EXP.000755 } else {756 set number {}757 foreach file [lsort -decreasing $files] {758 if [catch {759 regexp {.*\.EXP\.([0-9][0-9][0-9]).*} $file junk number760 regexp {0?0?([0-9]*)} $number junk number761 incr number762 }] {763 continue764 } else {765 break766 }767 }768 if {$number == ""} {set number 0}769 set file $expnam.EXP.[format "%3.3d" $number]770 }771 file copy $expgui(expfile) $file772 if [catch {exec gzip $file}] {773 exec echo "\n----------------------------------------------" >> $expnam.LST774 exec echo " Archiving $expnam.EXP as $file " >> $expnam.LST775 exec echo "----------------------------------------------\n" >> $expnam.LST776 } else {777 exec echo "\n----------------------------------------------" >> $expnam.LST778 exec echo " Archiving $expnam.EXP as $file.gz " >> $expnam.LST779 exec echo "----------------------------------------------\n" >> $expnam.LST780 }781 }782 } errmsg783 if {$errmsg != ""} {784 tk_dialog .warn Confirm "Error archiving the current .EXP file: $errmsg" warning 0 OK785 }786 }787 788 # save and optionally archive the expfile789 proc savearchiveexp {} {790 global expgui expmap791 if !$expgui(changed) return792 if $expgui(archive) archiveexp793 # add a history record794 exphistory add " EXPGUI [lindex $expgui(Revision) 1] [lindex $expmap(Revision) 1] ($expgui(changed) changes) -- [clock format [clock seconds]]"795 # now save the file796 expwrite $expgui(expfile)797 set expgui(changed) 0798 set expgui(expModifiedLast) [file mtime $expgui(expfile)]799 set expgui(last_History) [string range [string trim [lindex [exphistory last] 1]] 0 50 ]800 wm title . $expgui(expfile)801 set expgui(titleunchanged) 1802 # set convergence criterion803 InitLSvars804 717 } 805 718
Note: See TracChangeset
for help on using the changeset viewer.