Author |
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: May 21 2002 at 08:11 | IP Logged
|
|
|
These guys are on a roll changing the local weather pages; I've been using the sample code's GetWeather macro and twice in the last week they have changed something.
Everyone that uses this: stay on your toes! Maybe one of us should post fixed macros somewhere for the uninitiated?
Tony
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: May 21 2002 at 10:56 | IP Logged
|
|
|
Ive gone to WeatherUnderground and checked out the changes. I came up with a new GetWeather macro that should work with their current format. Im at work behind a firewall so I cant test. If someone could let me know if this is working, I'd appreciate it.
Just copy and paste the lines below into the Direct SQL window. Be sure and delete or rename any existing GetWeather macro before doing this.
insert into macroheader values ('GET WEATHER','GET WEATHER',4,4,252,96,0,0,0,12632256,0,1,1,'MACROS');
insert into macrodetail values ('GET WEATHER',1,15,'[MACRO1]',NULL,'left(f_geturl("www.weatherunderground.com/cgi-bin/findweather/getForecast?query=32707"),30000)');
insert into macrodetail values ('GET WEATHER',2,15,'[MACRO2]',NULL,'pos("[MACRO1]","<b>",pos("[MACRO1]","<td>Temperature</td>")) + 3');
insert into macrodetail values ('GET WEATHER',3,15,'[MACRO3]',NULL,'mid("[MACRO1]",[MACRO2],3)');
insert into macrodetail values ('GET WEATHER',4,15,'[MACRO4]',NULL,'"The temperature is " + if(isnumber("[MACRO3]"),"[MACRO3]",left("[MACRO3]",2)) + " degrees. "');
insert into macrodetail values ('GET WEATHER',5,15,'[MACRO2]',NULL,'pos("[MACRO1]","<b>",pos("[MACRO1]","<td>Humidity</td>",[MACRO2])) + 3');
insert into macrodetail values ('GET WEATHER',6,15,'[MACRO3]',NULL,'mid("[MACRO1]",[MACRO2],3)');
insert into macrodetail values ('GET WEATHER',7,15,'[MACRO4]',NULL,'"[MACRO4]" + "The humidity is " + if(isnumber("[MACRO3]"),"[MACRO3]",left("[MACRO3]",2)) + " percent. "');
insert into macrodetail values ('GET WEATHER',8,15,'[MACRO2]',NULL,'pos("[MACRO1]","<b>Forecast for ")');
insert into macrodetail values ('GET WEATHER',9,15,'[MACRO2]',NULL,'pos("[MACRO1]","<td align=left><b>",[MACRO2]) + 18');
insert into macrodetail values ('GET WEATHER',10,15,'[MACRO3]',NULL,'pos("[MACRO1]","</b>",[MACRO2])');
insert into macrodetail values ('GET WEATHER',11,15,'[MACRO4]',NULL,'"[MACRO4]" + "The forecast for " + mid("[MACRO1]",[MACRO2],[MACRO3] - [MACRO2]) + " is "');
insert into macrodetail values ('GET WEATHER',12,15,'[MACRO2]',NULL,'[MACRO3] + 9');
insert into macrodetail values ('GET WEATHER',13,15,'[MACRO3]',NULL,'pos("[MACRO1]","</td>",[MACRO2])');
insert into macrodetail values ('GET WEATHER',14,15,'[MACRO4]',NULL,'"[MACRO4]" + mid("[MACRO1]",[MACRO2],[MACRO3] - [MACRO2])');
insert into macrodetail values ('GET WEATHER',15,15,'[MACRO2]',NULL,'pos("[MACRO4]","winds")');
insert into macrodetail values ('GET WEATHER',16,16,'',NULL,'if([MACRO2] = 0,3,1)');
insert into macrodetail values ('GET WEATHER',17,15,'[MACRO4]',NULL,'replace("[MACRO4]",[MACRO2],5,"wins")');
insert into macrodetail values ('GET WEATHER',18,16,'',NULL,'- 3');
insert into macrodetail values ('GET WEATHER',19,9,'',NULL,'"[MACRO4]"');
For anyone wanting to use this macro, just change the zipcode in the second line from 32707 to your zipcode.
Thanks,
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: May 21 2002 at 20:43 | IP Logged
|
|
|
Works well! Thanks, Dave!
Tony
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: June 11 2002 at 08:34 | IP Logged
|
|
|
Looks like it's time to tweak it again! I'll try to look into it tonight.
Tony
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: June 11 2002 at 09:53 | IP Logged
|
|
|
Tony,
I took a look at it just a moment ago and cant find anything wrong. Im at work behind the firewall so cant test, but was wondering if you could point me where to look.
Thanks,
Dave.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: June 11 2002 at 14:58 | IP Logged
|
|
|
Tony,
I took a look at your event log online and saw what you're talking about. At 0711 and before, the GET WEATHER macro didnt seem to be working. The next time you checked at 0741 and subsequent times, it looks like everything was back to normal so by the time I looked at it, I didnt see any problems.
BTW, PowerHome now has functionality to work with proxy servers
PS. The guest mode access you've enabled is great!
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: June 11 2002 at 19:51 | IP Logged
|
|
|
Must have been a problem with my connection. Thanks for checking. I'll take a snapshot of the code so I can compare next time; live and learn!
Proxy support is great!
Can't wait til the next release!
Tony
|
Back to Top |
|
|
dmoreno Newbie
Joined: February 15 2002 Location: United States
Online Status: Offline Posts: 31
|
Posted: June 15 2002 at 00:19 | IP Logged
|
|
|
Tony and Dave, I have seen Tony's Code for the guest account. The problem is, I am using buttons on my site. I can't seem to link to the guest account using the buttons. Instead of logging into http://guest:guest@ipaddress.com:port#, It tries to log into http://guest/ph-cgi/main? that is totally different than the code I have written. Is there a way to use buttons for this type of like?
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: June 15 2002 at 01:13 | IP Logged
|
|
|
Cool! Someone else publicly online with PH!
Whatever is happening is weird with that button. The code looks correct; may be some glitch with Java, or, a syntax thing.
Tony
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: June 15 2002 at 20:08 | IP Logged
|
|
|
Don,
I took a look at your webpage code and as Tony pointed out, it looks fine from here and must be the way the applet is written. A way you could get it working would be to have the button load a simple html page that redirects to the guest login at PowerHome. This new page could have just the following:
<SCRIPT>location.replace("http://guest:guest@ipaddress.com:port#")</SCRIPT>
Hope this helps,
Dave.
|
Back to Top |
|
|
dmoreno Newbie
Joined: February 15 2002 Location: United States
Online Status: Offline Posts: 31
|
Posted: June 26 2002 at 21:02 | IP Logged
|
|
|
I wasn't able to use Java script for my Power home link. So I gave another try with macromedia. It works!!!! Hooray!!!!! By the way TonyNo, Do you have a static or dynamic IP? If Dynamic, How do you update your link to your powerhome? I use a freeware program called PostIt. It's really cool. It automatically updates my links, so I don't have to edit at all. If you can't find it I have a copy. Just go to my website, click on the Dons computer button then downloads. This works great with powerhome.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: June 27 2002 at 20:53 | IP Logged
|
|
|
I'm glad you got it to work! My IP is static (I'm one of the lucky ones).
I just went to your page, but, there are no buttons for the HA system! I like that clock, though!
Tony
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 21 2002 at 11:11 | IP Logged
|
|
|
I think Weather Underground has done something again! I've spent the last few hours trying to get the GET WEATHER macro to work again. Pulling out the temp and humidity works fine, but, the forecast does not.
Everything looks fine in the macro and the source code of the page. The important parts are within the 50,000 characters it pulls in. Simulating the code in a text editor by using the search function on the source HTML indicates it should work.
Dave, when you get a moment, can you give it a look?
Thanks - Tony
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 23 2002 at 14:04 | IP Logged
|
|
|
Tony,
I'll take a look at it. Im also going to look at using a different site as well since Weather Underground seems to like playing with the HTML a lot.
Dave.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 23 2002 at 14:59 | IP Logged
|
|
|
Tony,
Checked it out and it's not really anything that Weather Underground did other than the HTML getting longer and longer. It seems that the problem is with the POS function and the optional START parameter. Apparently the START parameter does not behave correctly when the value is in the vicinity of 34000. I would normally think that the problems would occur at 32767 but that does not seem to be the case. It does appear though that the internal datawindow POS function does seem to have some kind of bug associated with large START positions. Since this is internal to the PowerBuilder language, I have no control over it. However, it was simple enough to program around in the GETWEATHER macro. Below is a paste of the SQL for the new version:
insert into macroheader values ('GET WEATHER','GET WEATHER',4,4,252,96,0,0,0,12632256,0,1,1,'MACROS'); insert into macrodetail values ('GET WEATHER',1,15,'[LOCAL1]',NULL,'left(ph_geturl("http://www.weatherunderground.com/cgi-bin/findweather/getForecast?query=32707"),50000)'); insert into macrodetail values ('GET WEATHER',2,15,'[LOCAL2]',NULL,'pos(ph_getvar_s(1,1),"<b>",pos(ph_getvar_s(1,1),"<td>Temperature</td>")) + 3'); insert into macrodetail values ('GET WEATHER',3,15,'[LOCAL3]',NULL,'mid(ph_getvar_s(1,1),ph_getvar_n(1,2),3)'); insert into macrodetail values ('GET WEATHER',4,15,'[LOCAL4]',NULL,'"The temperature is " + if(isnumber(ph_getvar_s(1,3)),ph_getvar_s(1,3),left(ph_getvar_s(1,3),2)) + " degrees. "'); insert into macrodetail values ('GET WEATHER',5,15,'[LOCAL2]',NULL,'pos(ph_getvar_s(1,1),"<b>",pos(ph_getvar_s(1,1),"<td>Humidity</td>",ph_getvar_n(1,2))) + 3'); insert into macrodetail values ('GET WEATHER',6,15,'[LOCAL3]',NULL,'mid(ph_getvar_s(1,1),ph_getvar_n(1,2),3)'); insert into macrodetail values ('GET WEATHER',7,15,'[LOCAL4]',NULL,'ph_getvar_s(1,4) + "The humidity is " + if(isnumber(ph_getvar_s(1,3)),ph_getvar_s(1,3),left(ph_getvar_s(1,3),2)) + " percent. "'); insert into macrodetail values ('GET WEATHER',8,15,'[LOCAL2]',NULL,'pos(ph_getvar_s(1,1),"<b>Forecast for ")'); insert into macrodetail values ('GET WEATHER',9,15,'[LOCAL1]',NULL,'mid(ph_getvar_s(1,1),ph_getvar_n(1,2))'); insert into macrodetail values ('GET WEATHER',10,15,'[LOCAL2]',NULL,'pos(ph_getvar_s(1,1),"<td align=left><b>") + 18'); insert into macrodetail values ('GET WEATHER',11,15,'[LOCAL3]',NULL,'pos(ph_getvar_s(1,1),"</b>",ph_getvar_n(1,2))'); insert into macrodetail values ('GET WEATHER',12,15,'[LOCAL4]',NULL,'ph_getvar_s(1,4) + "The forecast for " + mid(ph_getvar_s(1,1),ph_getvar_n(1,2),ph_getvar_n(1,3) - ph_getvar_n(1,2)) + " is "'); insert into macrodetail values ('GET WEATHER',13,15,'[LOCAL2]',NULL,'ph_getvar_n(1,3) + 9'); insert into macrodetail values ('GET WEATHER',14,15,'[LOCAL3]',NULL,'pos(ph_getvar_s(1,1),"</td>",ph_getvar_n(1,2))'); insert into macrodetail values ('GET WEATHER',15,15,'[LOCAL4]',NULL,'ph_getvar_s(1,4) + mid(ph_getvar_s(1,1),ph_getvar_n(1,2),ph_getvar_n(1,3) - ph_getvar_n(1,2))'); insert into macrodetail values ('GET WEATHER',16,15,'[LOCAL2]',NULL,'pos(ph_getvar_s(1,4),"winds")'); insert into macrodetail values ('GET WEATHER',17,16,'',NULL,'if(ph_getvar_n(1,2) = 0,3,1)'); insert into macrodetail values ('GET WEATHER',18,15,'[LOCAL4]',NULL,'replace(ph_getvar_s(1,4),ph_getvar_n(1,2),5,"wins")'); insert into macrodetail values ('GET WEATHER',19,16,'',NULL,'- 3'); insert into macrodetail values ('GET WEATHER',20,9,'',NULL,'ph_getvar_s(1,4)');
The main difference is that when Im going to get the forecast (which is near the limit of the START parameter), I just throw away the HTML in the beginning. This will effectively reduce the values within the START parameter in the POS function.
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 23 2002 at 16:57 | IP Logged
|
|
|
Glad to see that it was an internal thing; I didn't think I saw anything wrong! I'll check that out tonight.
Thanks - Tony
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 23 2002 at 22:59 | IP Logged
|
|
|
I think the hyperlink messed it up. This works...
insert into macrodetail values ('GET WEATHER',1,15,'[LOCAL1]',NULL,'left(ph_geturl(www.weatherunderground.com/cgi-bin/findweather/getForecast?query=60014", 50000);
Trying to confuse me with the ph_getvar's, huh?
Thanks Dave! - Tony
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 25 2002 at 19:08 | IP Logged
|
|
|
I guess when I pasted the SQL into the messageboard edit, it automatically interpreted a portion of the code as a hyperlink and some quotes and parenthesis were omitted.
Ive edited the post and tested it so it should work properly now.
Thanks for keeping me on my toes Tony
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 23 2003 at 20:45 | IP Logged
|
|
|
Well, the temp has dropped here, and I have found a "bug" (at least in my area ) with the GetWeather macro. The line that says, "mid( "[LOCAL1]", [LOCAL2], 3)" assumes that the temperature will always be in the double-digits. That would be nice! I'll do some tweaking and post up so others that stole, I mean, use this macro where it's cold will not have stray characters pulled in.
Tony
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 23 2003 at 21:17 | IP Logged
|
|
|
Oh, I was wrong!
Changing...
Set System | LOCAL3 | mid( "[LOCAL1]", [LOCAL2], 3)
to...
Set System | LOCAL3 | pos("[LOCAL1]", "</b>", [LOCAL2]) Set System | LOCAL3 | mid( "[LOCAL1]", [LOCAL2], [LOCAL3] - [LOCAL2])
...fixes it.
Tony
|
Back to Top |
|
|
|
|