Mercurial > hg > egg-tcls
changeset 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 |
files | weather.tcl |
diffstat | 1 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/weather.tcl Tue Jul 21 18:26:28 2020 +0300 +++ b/weather.tcl Tue Jul 21 19:01:21 2020 +0300 @@ -258,12 +258,21 @@ set astr "" foreach aitem $umsg { set atmp $aitem + set aok 1 + + # Map tokens to values if they are set foreach {akey aval} [array get uvals] { - if {$aval != ""} { - set atmp [string map [list "@${akey}@" $aval] $atmp] + if {[string match "*@${akey}@*" $atmp]} { + if {$aval != ""} { + set atmp [string map [list "@${akey}@" $aval] $atmp] + } else { + set aok 0 + } } } - if {$atmp != $aitem || [string first "@" $aitem] < 0} { + + # Add item to string if all tokens in string were found + if {$aok} { append astr $atmp } }