1 2# JStrack: copyright 1997/2010 by Jim Graham, N5IAL, all rights reserved. 3# 4 5# Wipe the chart clean, and create empty copies of variables. 6 7proc wipeclean {{name ""}} { 8 global stinfo forecasts st_names st_times watchwarn stfile 9 global fc_tm_idx advisory_list 10 11 .warnings configure -foreground black 12 13 # create the watchwarn() list if it doesn't exist 14 if {[info exists watchwarn()] == 0} { set watchwarn() [list] } 15 set ucname [string toupper $name]* 16 set tmplist [list] 17 if {[string length $name] && [llength $watchwarn()]} { 18 foreach idx $watchwarn() { 19 if {[regexp $ucname $idx]} { lappend tmplist $idx } 20 } 21 array unset watchwarn $ucname 22 set watchwarn() [list] 23 set watchwarn() $tmplist 24 } else { 25 set watchwarn() [list] 26 } 27 28 if {$name == ""} { 29 all_wipeclean 30 return 31 } 32 33 set name [string toupper [file tail $name]] 34 set idx "STORM_$name*" 35 foreach i [array names stinfo "$idx"] { unset stinfo($i) } 36 foreach i [array names stfile "$idx"] { unset stfile($i) } 37 foreach i [array names advisory_list "$idx"] { unset advisory_list($i) } 38 foreach i [array names stradii "$idx"] { unset stradii($i) } 39 foreach i [array names fc_stradii "$idx"] { unset fc_stradii($i) } 40 41 set idx "$name*" 42 foreach i [array names st_times "$idx"] { unset st_times($i) } 43 foreach i [array names forecasts "$idx"] { unset forecasts($i) } 44 foreach i [array names fc_tm_idx "$idx"] { unset fc_tm_idx($i) } 45 46 set old_st_names $st_names 47 set st_names [list] 48 foreach nm $old_st_names { 49 if {[string compare $nm $name]} { lappend st_names $nm } 50 } 51 tk_wipe $name 52} 53 54 55proc all_wipeclean {} { 56 global stinfo forecasts st_names st_times watchwarn 57 global fc_tm_idx advisory_list 58 59 array unset watchwarn 60 set watchwarn() [list] 61 62 catch { unset stinfo } ; array set stinfo {} 63 catch { unset advisory_list } ; array set advisory_list {} 64 catch { unset forecasts } ; array set forecasts {} 65 catch { unset st_times } ; array set st_times {} 66 catch { unset fc_tm_idx } ; array set fc_tm_idx {} 67 catch { unset stradii } ; array set stradii {} 68 catch { unset fc_stradii } ; array set fc_stradii {} 69 catch { unset stfile } ; array set stfile {} 70 set st_names [list] 71 tk_wipe 72} 73 74 75# reload multiple storms 76 77proc mreload {args} { 78 global st_names 79 if {[llength $args] > 0} { 80 foreach i $args { reload $i } 81 } else { 82 if {[llength $st_names] > 0} { 83 foreach i $st_names { reload $i } 84 } 85 } 86} 87 88 89# reload the data for a given storm---simplified (a LOT) to kill errors. 90 91proc reload {{name ""}} { 92 global advisory_list current_storm_name storms stfile watchwarn st_names 93 94 set stlist [list] 95 if {[string length $name]} { 96 set stlist [list $name] 97 } else { 98 set stlist $st_names 99 } 100 foreach name $stlist { 101 wipeclean $name 102 set lcname [string tolower $name] 103 set filename "$storms/$lcname.trk" 104 if {[file exists $filename]} { 105 set stfile($lcname) $lcname 106 source $filename 107 newtrk_curr 108 plot_last $current_storm_name 109 } else { 110 puts "Can't find $filename ... $name not loaded." 111 } 112 } 113 set fakeset "" ;# prevents the last result from being displayed 114} 115 116 117 118 119