Own made weather script no errors however... - 22/10/07 05:26 PM
First off here's the code
Recongnizes both Canadian and U.S. Codes
I tried to use isalnum like this $did(weather,6) isalnum so for the postal code it makes sure its an alpha numeric string and well the script halts or something.
Recongnizes both Canadian and U.S. Codes
Code:
dialog weather { title "Weather Get - 15 Day View" size -1 -1 291 120 option dbu list 1, 2 1 240 152, size button "Get Weather", 2, 248 29 37 12, flat text "Zip/Post Code", 4, 248 6 36 8 edit "XXX XXX", 6, 253 16 27 10 box "", 7, 243 -1 44 45 } on *:dialog:weather:sclick:2:jobs alias jobs { did -r weather 1 if ($len($did(weather,6)) == 7) { %w.codes = $gettok($v1,1,32) $+(20,$gettok($v1,2,32)) | %w.codes = $replace(%w.codes,$chr(32),$chr(37)) | %wea = 1 | sockopen jobs www.accuweather.com 80 } ;I need a better check here ^ for postal code. elseif ($len($did(weather,6)) == 6) { echo -a Invalid Postal code XXX XXX is correct. / or You added a digit to many to zipcode } else { %w.codes = $did(weather,6) | unset %wea | sockopen jobs www.accuweather.com 80 } } on 1:sockopen:jobs:{ if (%wea) { .sockwrite -n jobs GET $+(/canada-forecast.asp?partner=accuweather&traveler=0&postalcode=,%w.codes,&metric=1&set=99) HTTP/1.1 .sockwrite -n jobs HOST: www.accuweather.com .sockwrite -n jobs $crlf } else { .sockwrite -n jobs GET $+(/forecast-15day.asp?partner=accuweather&traveler=0&zipChg=1&zipcode=,%w.codes,&metric=0) HTTP/1.1 .sockwrite -n jobs HOST: www.accuweather.com .sockwrite -n jobs $crlf } } on 1:sockread:jobs:{ if ($sockerr > 0) return var %x | sockread %x if ($sockbr == 0) return if (%x == $null) { return } if ($regex(%x,/(Locations|Days|Weekends|Radar|English|Developers|Details|Temperature)/b) == 1) { return } if ($regex(%x,/(fday|metric)/b) == 1) { %weather = $+([,$nhtml(%x),]) - } if ($regex(%x,/(forecastHeaderLeft|fcst|</div>|metric|&)/g) == 2) { if (smtextbox isin %x) { %weather = %weather $+([,$nhtml(%x),]) - } if (RealFeel isin %x) { %weather = %weather .:Tempature:. $+([,$nhtml(%x)) } if (Temp isin %x) { if ($len(%weather) > 20) { did -a weather 1 %weather $+($nhtml(%x),]) } else { return } } } } alias -l nhtml { return $remove($regsubex($1-,/( |°|^[^<]*>|<[^>]*>|<[^>]*$)/g,),$chr(9)) }
I tried to use isalnum like this $did(weather,6) isalnum so for the postal code it makes sure its an alpha numeric string and well the script halts or something.