From: Ian Jackson Date: Sun, 13 Feb 2011 19:32:20 +0000 (+0000) Subject: gui: read "train * is *" from .record into trainnum2train global array X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=b0ce8b83ba85c486e53eb19e5316b306399a991b;p=trains.git gui: read "train * is *" from .record into trainnum2train global array --- diff --git a/hostside/gui b/hostside/gui index 2472e72..78297c6 100755 --- a/hostside/gui +++ b/hostside/gui @@ -756,6 +756,7 @@ proc tractbrake-userinput {train tract brake speedw} { proc tractbrake-ensure {train} { upvar #0 speedcurve/$train sc + global trainnum2train if {[info exists sc]} return ;# try this only once set sc 0 @@ -771,12 +772,21 @@ proc tractbrake-ensure {train} { } while {[llength $sc] <= 126} { lappend sc x } while {[gets $f l] >= 0} { - if {![regexp {^train (\S+) step (\d+)=([0-9.]+)$} $l \ - dummy tr step velocity]} continue - if {[string compare $tr $train] || $step<=0 || $step>126} { - error "bad velocity line $l ?" {} {TRACTBRAKE SKIP} + if {[regexp {^train (\S+) step (\d+)=([0-9.]+)$} $l \ + dummy tr step velocity]} { + if {[string compare $tr $train] || $step<=0 || $step>126} { + error "bad velocity line $train $l ?" + } + set sc [lreplace $sc $step $step $velocity] + } elseif {[regexp {^train (\S+) is (\d+) } $l \ + dummy tr trainnum]} { + if {[string compare $tr $train]} { + error "bad train line $train $l ?" + } + set trainnum2train($trainnum) $tr + } else { + # fine, whatever } - set sc [lreplace $sc $step $step $velocity] } close $f if {[lsearch -exact $sc x]>=0} {