comparison weather.tcl @ 568:1ef78f020573

weather: All tokens in the weather format string item must have a value for the item to be added to the output string.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 21 Jul 2020 19:01:21 +0300
parents 601ef87a1c42
children 1fbee4891dbc
comparison
equal deleted inserted replaced
567:601ef87a1c42 568:1ef78f020573
256 } 256 }
257 257
258 set astr "" 258 set astr ""
259 foreach aitem $umsg { 259 foreach aitem $umsg {
260 set atmp $aitem 260 set atmp $aitem
261 set aok 1
262
263 # Map tokens to values if they are set
261 foreach {akey aval} [array get uvals] { 264 foreach {akey aval} [array get uvals] {
262 if {$aval != ""} { 265 if {[string match "*@${akey}@*" $atmp]} {
263 set atmp [string map [list "@${akey}@" $aval] $atmp] 266 if {$aval != ""} {
264 } 267 set atmp [string map [list "@${akey}@" $aval] $atmp]
265 } 268 } else {
266 if {$atmp != $aitem || [string first "@" $aitem] < 0} { 269 set aok 0
270 }
271 }
272 }
273
274 # Add item to string if all tokens in string were found
275 if {$aok} {
267 append astr $atmp 276 append astr $atmp
268 } 277 }
269 } 278 }
270 279
271 return $astr 280 return $astr