|
RockSteady
|
RockSteady
|
on *:text:!weather *:#: {
set %zip.code $2
set %weather.chan $chan
weather
}
alias weather { write -c E:\weather.txt | write -c E:\weather2.txt | window -eh @Weather | sockopen weather weatherforyou.com 80 | .timer 1 5 reportweather }
on *:sockread:weather: {
//sockread %weather
aline 8 @Weather %weather
write weather.txt %weather
}
on *:sockopen:weather: {
sockwrite -n $sockname GET /cgi-bin/hw3/hw3.cgi?forecast=zandh&pands= $+ %zip.code $+ &Submit=Get+Forecast HTTP/1.1
sockwrite -n $sockname Host: weatherforyou.com $+ $crlf $+ $crlf
}
;http://www.weatherforyou.com/cgi-bin/hw3/hw3.cgi?forecast=zandh&pands=55110&Submit=Get+Forecast
alias reportweather {
filter -wf @Weather E:\weather2.txt *Local Forecast*
filter -wf @Weather E:\weather2.txt *°F*
filter -wf @Weather E:\weather2.txt *°C*
.timer 1 1 report2
}
alias report2 {
var %weather.one = $read(E:\weather2.txt,1)
var %weather.one = $remove(%weather.one,<span class="titlewhite">)
var %weather.one = $remove(%weather.one,Local Forecast</span><br>)
set %weather.City %weather.one
var %weather.two = $read(E:\weather2.txt,2)
var %weather.two = $remove(%weather.two,<font face="Verdana)
var %weather.two = $remove(%weather.two,Arial" size="4"><b>)
var %weather.two = $remove(%weather.two,</b></font><br>)
var %weather.two = $replace(%weather.two,&deg;,$chr(176))
set %weather.temp Current Temp: %weather.two
var %weather.three = $read(E:\weather2.txt,3)
var %weather.three = $remove(%weather.three,<)
var %weather.three = $remove(%weather.three,td align="right" class="smalldefault">)
var %weather.three = $remove(%weather.three,/td>)
var %weather.three = $replace(%weather.three,&deg;,$chr(176))
set %weather.dew Current Dewpoint: %weather.three
window -c @Weather
humidity
}
alias humidity {
var %a = $lines(E:\weather.txt)
var %b = 1
:begin
var %read = $read(E:\weather.txt, %b)
if (%b <= %a) {
if (Humidity isin %read) && (META !isin %read) {
set %humidity Humidity: $read(E:\weather.txt, $calc(%b + 1))
set %humidity $remove(%humidity,<td align="right" class="smalldefault">,</td>)
}
inc %b
goto begin
}
else { goto end }
:end
weathersay
}
alias weathersay {
msg %weather.chan %weather.City
msg %weather.chan %weather.temp
msg %weather.chan %weather.dew
msg %weather.chan $remove(%humidity,<td align="right" class="smalldefault">,</td>)
}
!weather 55110 OutPuts: Saint Paul, MN Current Temp: ,57°F Current Dewpoint: 36°F Humidity: 39% A: I cant get rid of the comma on the temp, ive tried to do something like hi $+ thevar and tried to tokenize it but /me shrugs. B: I get a butt load of - * /aline: insufficient parameters (line 19, script3.mrc) - Not sure how to prevent this. Also sorry for the side scroll I know I hate it to lol
|
|
|
|
Joined: Mar 2003
Posts: 1,256
Hoopy frood
|
Hoopy frood
Joined: Mar 2003
Posts: 1,256 |
A: we cannot possible offer any decent advise, so I'll go with indecent -- did you try using $remove(%somevar,$chr(44)). B: you did a good thing providing the line number where the error occurs, but in line 19 of your code pasted here there is no aline command. It would be nice if next time you would paste the line separately or indicate where it is. That said, I wil assume the only aline command in your code is the one causing the error. In which case the solution is simple: not everytime the sockread event triggers, does your variable %weather get a value. In that case, your line aline 8 @Weather %weather is interpreted by mIRC as aline 8 @Weather. mIRC will then complain that it is to write something to the window without knowing what, hence the error. The solution is simple:
if (%weather) aline 8 @Weather %weather
|
|
|
|
RockSteady
|
RockSteady
|
Cool that did the trick I tried $remove before but for some reason i had a different $chr number. One last question. Im getting - * /aline: line too long (line 19, script3.mrc) - I know id have to make a loop somehow but not quite sure how to go about that. EDIT Correction the if statement cut the aline errors down but I still receive them on the same line number if (%weather) aline 8 @Weather %weather | write weather.txt %weather EDIT Is there a way to just supress these errors?
Last edited by RockSteady; 12/05/04 09:10 AM.
|
|
|
|
Joined: Mar 2003
Posts: 1,256
Hoopy frood
|
Hoopy frood
Joined: Mar 2003
Posts: 1,256 |
The line-too-long error you mention now is a whole other ballgame from the one before. before, there was no data in the line, now there is too much. Variables are limited in their length to 900-something characters. Anything longer produces this problem. As far as I understand, the only way to get around is to use binary variables to store the stuff you read from the socket. Can't help you there tho.
|
|
|
|
RockSteady
|
RockSteady
|
Thanks Ill try to poke around that stuff
|
|
|
|
Iori
|
Iori
|
You might be better off using bread\bwrite in the sockread and the file handling commands to parse it. on *:text:!weather *:#:{
if $sock(weather) { msg # A weather search is already in progress. | return }
set %weather.zip $2
set %weather.chan $chan
weather
}
alias weather {
write -c E:\weather.txt
sockopen weather weatherforyou.com 80
}
on *:sockread:weather:{
if $sockerr { echo -a * $!sockerr ( $+ $sockname $+ ): $sock($sockname).wsmsg | return }
sockread -f &weather
bwrite E:\weather.txt -1 -1 &weather
}
on *:sockclose:weather:{
if $file(E:\weather.txt) { weather.parse }
}
alias weather.parse {
var %loc,%tmp,%hum,%dew
.fopen w E:\weather.txt
.fseek -w w *was not found*
if !$feof { msg %weather.chan * Weather: Location $+([,%weather.zip,]) not found. | .fclose w | return }
else .fseek w 0
.fseek -w w *Reported at*
%loc = $gettok($gettok($gettok($fread(w),2,62),1,60),3-,32)
.fseek -w w *&deg;f*
%tmp = $replace($gettok($gettok($fread(w),3,62),1,60),&deg;,°)
.fseek -w w *Humidity:* | .echo -q $fread(w)
%hum = $gettok($gettok($fread(w),2,62),1,60)
.fseek -w w *Dewpoint* | .echo -q $fread(w)
%dew = $replace($gettok($gettok($fread(w),2,62),1,60),&deg;,°)
.fclose w
msg %weather.chan * Weather for %loc Current: %tmp Humidity: %hum Dewpoint: %dew
unset %weather.*
}
on *:sockopen:weather:{
if $sockerr { echo -a * $!sockerr ( $+ $sockname $+ ): $sock($sockname).wsmsg | return }
sockwrite -n $sockname GET /cgi-bin/hw3/hw3.cgi?forecast=zandh&pands= $+ %weather.zip $+ &Submit=Get+Forecast HTTP/1.1
sockwrite -n $sockname Host: weatherforyou.com $+ $crlf $+ $crlf
}
|
|
|
|
RockSteady
|
RockSteady
|
Dude thanks now I can use this to help solve my other problems EDIT Hmm its a bit laggy any clue how to sped it up i noticed its all bwrites is it just b/c of that?
Last edited by RockSteady; 18/05/04 11:37 AM.
|
|
|
|
|