diff weather.tcl @ 279:f6dc673adfa1

weather: Reorder some function arguments.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 23 Jan 2015 12:23:43 +0200
parents 38a5bce4b078
children 3893192d7aff
line wrap: on
line diff
--- a/weather.tcl	Fri Jan 23 11:54:10 2015 +0200
+++ b/weather.tcl	Fri Jan 23 12:23:43 2015 +0200
@@ -147,8 +147,8 @@
 
 
 # Produce one location of weather data as a string
-proc weather_get_data {ukey udata} {
   set str "\002[lindex $udata 0]\002, mitattu klo [weather_ctime [lindex $udata 2]]: \002[lindex $udata 3]°C\002"
+proc weather_get_data {udata ukey} {
   if {[lindex $udata 1] == 0} {
     append str [weather_item $udata 5 ", @@"]
     append str [weather_item $udata 6 ", keli @@"]
@@ -163,9 +163,9 @@
 
 
 # Get data by location key
-proc weather_get_key {ukey} {
+proc weather_get_by_key {ukey} {
   global weather_data
-  return [weather_get_data $ukey $weather_data($ukey)]
+  return [weather_get_data $weather_data($ukey) $ukey]
 }
 
 
@@ -392,18 +392,18 @@
   foreach rarg $rarglist {
     if {$rarg == "min"} {
       # Min temp
-      set umin [weather_get_key "w_min"]
+      set umin [weather_get_by_key "w_min"]
       weather_msg $upublic $unick $uchan "Min: $umin"
       incr nresults
     } elseif {$rarg == "max"} {
       # Max temp
-      set umax [weather_get_key "w_max"]
+      set umax [weather_get_by_key "w_max"]
       weather_msg $upublic $unick $uchan "Max: $umax"
       incr nresults
     } elseif {$rarg == "minmax" || $rarg == "min max" || $rarg == "maxmin" || $rarg == "max min"} {
       # Min & Max temps
-      set umin [weather_get_key "w_min"]
-      set umax [weather_get_key "w_max"]
+      set umin [weather_get_by_key "w_min"]
+      set umax [weather_get_by_key "w_max"]
       weather_msg $upublic $unick $uchan "Min: $umin | Max: $umax"
       incr nresults
     } else {
@@ -413,7 +413,7 @@
       foreach {ukey uvalue} [array get weather_data] {
         if {![string match "w_*" $ukey] && [string match -nocase "*${rarg}*" $ukey]} {
           if {[llength $uvalue] > 0} {
-            weather_msg $upublic $unick $uchan [weather_get_data $ukey $uvalue]
+            weather_msg $upublic $unick $uchan [weather_get_data $uvalue $ukey]
             incr nresults
           } else {
             weather_msg $upublic $unick $uchan $weather_msg_no_results [list $ukey]