This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Sun and Moon script

Help for those learning Tcl or writing their own scripts.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Code: Select all

https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/${arg}/next5days?key=YOUR_API_KEY
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
bayo
Voice
Posts: 15
Joined: Tue Jan 25, 2022 4:14 pm
Location: Bulgaria
Contact:

Post by bayo »

Hi. It doesn't work. Says

Tcl error [::Visualcrossing::forecast_weather]: missing value to go with key

Code: Select all

### The Third Proc for 3 days Forecast 
proc ::Visualcrossing::forecast_weather {nick uhost hand chan arg} {
	set forecast_data [::Visualcrossing::download_weather https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/${arg}/next3days?[http::formatQuery unitGroup metric key $::Visualcrossing::key]]
	if {$arg == ""} { putserv "PRIVMSG $chan :Sintax: !3 location" ; return }
	set forecast_dict [::json::json2dict $forecast_data]
	
	set desc [dict get $forecast_data description]
	
	putserv "PRIVMSG $chan :TEST $desc" 
}
Online
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

When error occures, use .set errorInfo to let us know if the trouble is with formatQuery or with json2dict.
I guess it's json2dict, so dump forecast_data then we can understand the trouble
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Pasted code looks fine.

Post by SpiKe^^ »

Maybe this is the code it's bitching about:

Code: Select all

?[http::formatQuery unitGroup metric key $::Visualcrossing::key]
...but to me that chunk seems ok, though I might call http::formatQuery more correctly

Code: Select all

?[::http::formatQuery unitGroup metric key $::Visualcrossing::key]
It does fit the syntax from the manual
::http::formatQuery key value ?key value ...?
as it seems to have an equal number of keys and values.



If that doesn't work, try:

Code: Select all

set forecast_data [::Visualcrossing::download_weather https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/${arg}/next3days?unitGroup=metric&key=$::Visualcrossing::key]
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Post Reply