Author |
|
jpcurcio Senior Member
Joined: April 01 2007 Location: United States
Online Status: Offline Posts: 119
|
Posted: April 23 2007 at 02:47 | IP Logged
|
|
|
I've been trying to use the "get weather" macro posted by TonyNo, and run up against a couple issues. The "current forecast" doesn't seem to work reliably, and I think I found the issue. My problem is that I don't know how to fix it.
When the macro grabs the forecast, it inevitably overruns the 1024 character limit of the CURFORECAST global variable. If this happens without properly closing a statement (such as a <img src="http://), it won't parse the variable properly in PH and therefore won't announce the weather.
Has anyone found a workaround for this? My first thought was to dump the wunderground image text, since it's useless for use in PH, but that would probably be difficult
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 23 2007 at 07:40 | IP Logged
|
|
|
I've not seen this, so I'm interested in anyone else having this problem.
Something like this should do it...
SET SYSTEM [LOCALx] ph_replaceallregex( "<img ~255>", "", [LOCALx], 0)
|
Back to Top |
|
|
jpcurcio Senior Member
Joined: April 01 2007 Location: United States
Online Status: Offline Posts: 119
|
Posted: April 23 2007 at 12:09 | IP Logged
|
|
|
TonyNo wrote:
I've not seen this, so I'm interested in anyone else having this problem.
Something like this should do it...
SET SYSTEM [LOCALx] ph_replaceallregex( "<img ~255>", "", [LOCALx], 0) |
|
|
That sounds like it will work... but it raises (yet another) question. Can I nest the ph_regexdiff() statement used to grab the forecast inside the ph_replaceallregex()? I'm assuming that I can...
-JPC
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: April 23 2007 at 13:56 | IP Logged
|
|
|
I use the following weather macro which I copied from this board and have used for over a year. I think it was written by TonyNo and then he subsequently modified it to the macro you are using now. I only offer it because I note that it snaps the forecast differently and might be of some help.
insert into macroheader values ('GET WEATHER','GET WEATHER',1,1,1);
insert into macrodetail values ('GET WEATHER',1,37,'',NULL,'The next line snaps out the temperature in degrees farenheight.',0,'');
insert into macrodetail values ('GET WEATHER',2,15,'[LOCAL1] ',NULL,'ph_geturl("http://www.weatherunderground.com/cgi-bin /findweather/getForecast?query=11733")',0,'');
insert into macrodetail values ('GET WEATHER',3,15,'[LOCAL2] ',NULL,'ph_regexsnap("<nobr><b>\(.+\)</b>& nbsp;°F</nobr>","[LOCAL1]",1,0)',0,'');
insert into macrodetail values ('GET WEATHER',4,37,'',NULL,'The next line uses the regexdiff function to get the humidity.',0,'');
insert into macrodetail values ('GET WEATHER',5,15,'[LOCAL3] ',NULL,'ph_regexdiff(">Humidity:</td>~255<nobr&g t;<b>","%</b></nobr>"," [LOCAL1]",1,0)',0,'');
insert into macrodetail values ('GET WEATHER',6,37,'',NULL,'The next line gets wind in miles per hour.',0,'');
insert into macrodetail values ('GET WEATHER',7,15,'[LOCAL4]',NULL,'ph_regexdiff(">Wind Gust:</td>~255<nobr><b>","</b> ","[LOCAL1]",1,0)',0,'');
insert into macrodetail values ('GET WEATHER',8,37,'',NULL,'The next line gets the current forecast.',0,'');
insert into macrodetail values ('GET WEATHER',9,15,'[LOCAL5]',NULL,'ph_regexdiff(''<h4>Updated:~255<div id="b">~255<div>'',''</div>'',"[LOCAL1]",1,0)',0,'');
insert into macrodetail values ('GET WEATHER',10,41,'ITUNES MUTE',NULL,'',0,'');
insert into macrodetail values ('GET WEATHER',11,9,'',NULL,'"Temperature: [LOCAL2] degrees~r~n.Humidity: [LOCAL3]%~r~n.Win[LOCAL4] miles per hour~r~n.Forecast: [LOCAL5]."',0,'');
insert into macrodetail values ('GET WEATHER',12,31,'',NULL,'20',0,'');
insert into macrodetail values ('GET WEATHER',13,9,'',NULL,'"Once again, the Temperature is. [LOCAL2] degrees"',0,'');
insert into macrodetail values ('GET WEATHER',14,31,'',NULL,'5',0,'');
insert into macrodetail values ('GET WEATHER',15,41,'ITUNES MUTE',NULL,'',0,'');
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 23 2007 at 14:02 | IP Logged
|
|
|
Quote:
Can I nest the ph_regexdiff() statement used to grab the forecast inside the ph_replaceallregex()? |
|
|
Hmm. That may work.
Thanks Nadler.
|
Back to Top |
|
|
jpcurcio Senior Member
Joined: April 01 2007 Location: United States
Online Status: Offline Posts: 119
|
Posted: April 23 2007 at 14:36 | IP Logged
|
|
|
TonyNo wrote:
Quote:
Can I nest the ph_regexdiff() statement used to grab the forecast inside the ph_replaceallregex()? |
|
|
Hmm. That may work.
|
|
|
The main reason I want to do this is in order to grab as much of the forecast as possible. For each line in the forecast, there is a longer line containing the URL of the graphic. I figure that if I kill the <img src....> stuff first, I'd get more of the broadcast to fit into the variable. Once it gets stored, it will get truncated...
I tried the nesting briefly this morning before heading to work, but it didn't work. I'll investigate further tonight, when I have some time.
I'll also try Nadler's code as well, to see if that makes it better.
-jpc
|
Back to Top |
|
|
jpcurcio Senior Member
Joined: April 01 2007 Location: United States
Online Status: Offline Posts: 119
|
Posted: April 23 2007 at 23:05 | IP Logged
|
|
|
OK... I've got it now. I used the ph_replaceallregex() function suggested by Tony, and filtered out the image text. I also nested the ph_regexdiff() inside the ph_replaceallregex() for conciseness. This will allow me to get the entire forecast string in the one variable without overflowing.
Here is the code snippet that I used:
ph_replaceallregex(
'<img src=.*~255 >',
" ",
ph_regexdiff(
'<b>Forecast as of~255<td align="left">',
'<div align',
"[LOCAL1]",
1,
0
),
0
)
Thanks again for the help, guys... couldn't have done it without you!!
-JPC
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: October 17 2009 at 05:41 | IP Logged
|
|
|
Hey guys,
I can't seem to be able to extract the windspeed (Wind direction is OK) out of the following page:
mobile.wunderground.com/global/stations/06370.html
Like I said: I can get the direction out but the speed keeps on being empty.
I tried this amongst other things:
ph_regexsnap('at~255<span class="nowrap"><b>\(.+\)</b> mph</spa n>',"[LOCAL1]",1,0)
can you help me with this?
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: October 17 2009 at 09:26 | IP Logged
|
|
|
What happens when you narrow it down?
ph_regexsnap('mph</span>',"[LOCAL1]",1,0)
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: October 17 2009 at 13:16 | IP Logged
|
|
|
You've got to see it to believe it:
Code:
Oct 17 2009 19:13:59 User Message 4.0
Oct 17 2009 19:13:59 Global Variable Global variable WIND changed from NNW to 4.0
Oct 17 2009 19:13:59 User Message 4.0
Oct 17 2009 19:13:57 Macro & nbsp; Macro WINDS executed.
|
|
|
BULLSEYE: You hit the spot right-on!
I am going to try this the following days!
Keep you informed....
Edited by krommetje - October 17 2009 at 13:18
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: October 18 2009 at 06:32 | IP Logged
|
|
|
I have a snipped javascript which calculates the Winchill from Temperature and windspped, I would like to convert this into a PH-like formula:
Code:
function doSteadman(temp, speed) {
// Berekening van de wind-chill equivalent temperature volgens Robert G. Steadman
// Bert van Dijk, 20050907
var chill = 0;
if (speed == "") {
alert("U heeft de windsnelheid niet ingevuld") }
else; {
if (temp == "") {
alert("U heeft de temperatuur niet ingevuld") }
else {
temp = checkDecimal(temp);
speed = checkDecimal(speed);
// Formule volgens Steadman:
//chill = 1.41 - (1.162 * speed) + (0.980 * temp) + (0.0124 * speed * speed) + (0.0185 * speed * temp);
// volgens A.Court:
// chill = 33 + (temp - 33) * (0.550 + (0.417 * Math.sqrt(speed)) - (0.0454 * speed));
// volgens Siple en Passel:
// chill = 33 - (((12.12 + (11.6 * Math.sqrt(speed)) - (1.16 * speed)) * (33 - temp)) / 25.57);
// de Canadese methode:
// chill = 13.12 + (0.6215 * temp) + (0.3965 * (temp - 28.679) * Math.pow(speed, 0.16));
// volgens JAG/TI
speed = speed * 3.6;
chill = 13.12 + (0.6215 * temp) - (11.37 * Math.pow(speed, 0.16)) + (0.3965 * temp * Math.pow(speed, 0.16));
if (speed < 1.8 || chill > temp) chill = temp;
chill = Math.round(chill * 10) / 10;
return chill;
}
}
}
|
|
|
how do I start with this?
Peter
Edited by krommetje - October 18 2009 at 06:32
|
Back to Top |
|
|
jbbtex Senior Member
Joined: February 15 2007 Location: United States
Online Status: Offline Posts: 181
|
Posted: October 18 2009 at 20:19 | IP Logged
|
|
|
This is what I use - temperature in Fahrenheit, windspeed in mph:
Code:
ph_setvar_a(1,8,35.74 + (.6215 * {CURTEMP}) - (35.75 * ({CURWINDSPEED} ^ .16)) + (.4275 * ({CURTEMP} * ({CURWINDSPEED} ^ .16)))) |
|
|
This sets LOCAL8 to the result of the formula. CURTEMP and CURWINDSPEED are global variables. CURTEMP comes from a sensor in my backyard and CURWINDSPEED comes from Weatherunderground.
I got the formula here. http://www.usatoday.com/weather/resources/basics/windchill/w ind-chill-formulas.htm
__________________ Brady
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity." - Gen. George S. Patton
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: October 25 2009 at 09:54 | IP Logged
|
|
|
Got it and entered it into my own macro....
now i have all the values I need....
thanx
|
Back to Top |
|
|
|
|