Mercurial > hg > egg-tcls
comparison weather.tcl @ 167:3a375ee7c106
weather: More flexible data handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 02 Jun 2014 21:43:46 +0300 |
parents | ff64ef21c20d |
children | 5434903331df |
comparison
equal
deleted
inserted
replaced
166:c8d5f3a7c4b7 | 167:3a375ee7c106 |
---|---|
171 return $uname | 171 return $uname |
172 } | 172 } |
173 | 173 |
174 | 174 |
175 #------------------------------------------------------------------------- | 175 #------------------------------------------------------------------------- |
176 proc weather_item {udata uindex ufmt} { | |
177 if {[llength $udata] > $uindex && [lindex $udata $uindex] != ""} { | |
178 set utmp [lindex $udata $uindex] | |
179 return [string map [list "@@" $utmp] $ufmt] | |
180 } | |
181 return "" | |
182 } | |
183 | |
176 proc weather_get_data {ukey udata} { | 184 proc weather_get_data {ukey udata} { |
177 set str "\002[lindex $udata 0]\002, mitattu klo [weather_ctime [lindex $udata 1]]: \002[lindex $udata 2]°C\002" | 185 set str "\002[lindex $udata 0]\002, mitattu klo [weather_ctime [lindex $udata 1]]: \002[lindex $udata 2]°C\002" |
178 if {[llength $udata] > 3} { | 186 append str [weather_item $udata 4 ", @@"] |
179 append str ", tien pinta [lindex $udata 3]°C" | 187 append str [weather_item $udata 5 ", kosteus \002@@%\002"] |
180 } | 188 append str [weather_item $udata 3 ", tien pinta @@°C"] |
181 if {[llength $udata] > 4} { | |
182 append str ", [lindex $udata 4]" | |
183 } | |
184 return "${str}." | 189 return "${str}." |
185 } | 190 } |
186 | 191 |
187 | 192 |
188 proc weather_get_key {ukey} { | 193 proc weather_get_key {ukey} { |