Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: import macro from SQL trouble Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
kemaa
Newbie
Newbie


Joined: October 17 2007
Online Status: Offline
Posts: 18
Posted: October 17 2007 at 18:46 | IP Logged Quote kemaa

I am trying to import the GET WEATHER macro using the SQL commands. The directions I'm following seem clear enough but I'm not getting the same results. This is the text I'm running from (from http://www.diy-ha.com/infofrominternet.php)

"First, before reading any further, load Powerhome, go to the Multi Editor, set it to SQL, and paste in the contents of this file[see file below]. Then, create a Global Variable called CURTEMP

This will set up the basic structure that you need to grab data. It should create a macro called Test. Go into Powerhome Explorer and load this macro."

The file they had me download was:
"insert into macroheader values ('TEST','TEST',0,0,1);
insert into macrodetail values ('TEST',1,15,'[LOCAL1]',NULL,'ph_geturl( "mobile.wunderground.com/cgi-bin/findweather/getForecast?bra nd=mobile&query=19004")',0,'');
insert into macrodetail values ('TEST',2,15,'[LOCAL1]',NULL,'ph_readfile ( "C:\Program Files\powerhome\wum.htm" )',1,'');
insert into macrodetail values ('TEST',3,38,'',1,'ph_writefile ( "C:\Program Files\powerhome\wum.htm", 1, "[LOCAL1]" )',1,'');
insert into macrodetail values ('TEST',4,10,'CURTEMP',NULL,'ph_regexsnap(''<tr><td >Temperature</td>~255<b>\(.+\)</b>° ;F'',"[LOCAL1]",1,0)',0,''); "

I don't see any macro called TEST creating itself when I make the global variable CURTEMP. Can someone please help me with this? I'm sure it is a small error that I'm missing like not clicking apply or something like that.

Thank you.

Back to Top View kemaa's Profile Search for other posts by kemaa
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: October 17 2007 at 21:29 | IP Logged Quote TonyNo

Whose site is that?! At least they give me credit!

The TEST macro will appear when you paste in that text into the SQL editor and execute it.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
kemaa
Newbie
Newbie


Joined: October 17 2007
Online Status: Offline
Posts: 18
Posted: October 23 2007 at 16:05 | IP Logged Quote kemaa

Thanks, I was able to get the macro to load. When I ran it I had nothing happen. I created the global variable CURTEMP and I see the wun.htm file (which is blank). Is there something else that I need to do to get this to work?
Back to Top View kemaa's Profile Search for other posts by kemaa
 
kemaa
Newbie
Newbie


Joined: October 17 2007
Online Status: Offline
Posts: 18
Posted: November 01 2007 at 20:42 | IP Logged Quote kemaa

From reading a little bit on the help menu it says that the geturl function uses the proxy server set up in Setup. I haven't changed this from its default settings. I don't opperate my machine on a proxy (that I know of). Would this have anything to do with my lack of data coming back?
Back to Top View kemaa's Profile Search for other posts by kemaa
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: November 01 2007 at 20:59 | IP Logged Quote TonyNo

No, if you don't have a proxy, you should be fine.

So, you now have the TEST macro if you click on Macros in the PH Explorer?
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
kemaa
Newbie
Newbie


Joined: October 17 2007
Online Status: Offline
Posts: 18
Posted: November 02 2007 at 16:25 | IP Logged Quote kemaa

Yes. When I select that macro from the Macro/Formula dropdown box and click run it creates the wun.htm file but it is blank and the value of CURTEMP is still blank.
Back to Top View kemaa's Profile Search for other posts by kemaa
 
jbbtex
Senior Member
Senior Member


Joined: February 15 2007
Location: United States
Online Status: Offline
Posts: 181
Posted: November 02 2007 at 17:33 | IP Logged Quote jbbtex

kemaa,

If the second line of the TEST macro is:
Set System     [LOCAL1]       ph_readfile ( "C:\Program Files\powerhome\wum.htm" )


Click the Skip box on that line and then run the macro. When I run it with that line skipped it works fine. If that line executes, wun.htm is blank.

__________________
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 View jbbtex's Profile Search for other posts by jbbtex
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: November 02 2007 at 19:23 | IP Logged Quote TonyNo

Wow! That line was in there for testing. I guess I forgot to check Skip when I exported! Sorry!
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
jbbtex
Senior Member
Senior Member


Joined: February 15 2007
Location: United States
Online Status: Offline
Posts: 181
Posted: November 02 2007 at 19:57 | IP Logged Quote jbbtex

Tony,

It is checked on yours. The one he mentions above is here: http://www.diy-ha.com/GetWeatherSimplified.txt

It is skipped there too, but on the tutorial page they have a screen shot that doesn't show the Skip box. And this: "Lines 2-3 in the macro write a local file--you shouldn't have to bother editing this."

__________________
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 View jbbtex's Profile Search for other posts by jbbtex
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: November 03 2007 at 09:12 | IP Logged Quote TonyNo

Ah, ok!
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
kemaa
Newbie
Newbie


Joined: October 17 2007
Online Status: Offline
Posts: 18
Posted: November 03 2007 at 11:12 | IP Logged Quote kemaa

I'm still having some problems but I'm narrowing down the cause. When I run formula checker on the formulas for each line, the formula evaluates to:
HTTP/1.1 400 Bad Request
Date: Sat, 03 Nov 2007 15:07:42 GMT
Server: Apache/1.3.33 (Unix) PHP/4.4.0
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>400 Bad Request</TITLE>
</HEAD><BODY>
<H1>Bad Request</H1>
Your browser sent a request that this server could not understand.<P>
The request line contained invalid characters following the protocol string.<P>
<P>
<HR>
<ADDRESS>Apache/1.3.33 Server at l3a10.wunderground.com Port 80</ADDRESS>
</BODY></HTML>


I tried playing around with the address (adding a http:// at the front of the address just in case but still no luck. I'm certain that my problem is stemming from the lack of web page results. I can load the page no problem in my browser so I'm figuring something is wrong with the call.

Thank you for your help so far. If I can get this to work I'll definately start to run with this quickly.

Edited by kemaa - November 03 2007 at 11:15
Back to Top View kemaa's Profile Search for other posts by kemaa
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: November 03 2007 at 12:48 | IP Logged Quote TonyNo

You are using this?

ph_geturl( "mobile.wunderground.com/cgi-bin/findweather/getForecast?bra nd=mobile&query=ZIP")
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
kemaa
Newbie
Newbie


Joined: October 17 2007
Online Status: Offline
Posts: 18
Posted: November 03 2007 at 15:35 | IP Logged Quote kemaa

I've noticed that somehow spaces were inserted into the code from the import. I fixed two different pieces already. There was a break that I can see in your post as well. (brand=mobile not bra nd=mobile). I have been playing around with the formula for ph_regexsnap. I changed it because I couldn't find the ~255 anywhere in the returned text. This is now my formula:

ph_regexsnap('<tr><td>Temperature</td>
<td>
<span class="nowrap"><b>\(.+\)</b>°F,"[LOCAL1]",1,0)

This returns a ! into CURTEMP, which is a step in the right direction because I'm getting a return value finally. According to what I've been reading in the help file, I should have picked out the right portion of the string to grab.
Back to Top View kemaa's Profile Search for other posts by kemaa
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: November 03 2007 at 16:40 | IP Logged Quote TonyNo

Yup, the board here adds spaces frequently.

The ~255 is regex for "skip stuff". This is what it should be...

ph_regexsnap('<tr><td>Temperature</td>~255 <b>\(.+\)</b>°F'," [LOCAL1]",1,0)

Delete any spaces.

An "!" means that the formula has an error.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
kemaa
Newbie
Newbie


Joined: October 17 2007
Online Status: Offline
Posts: 18
Posted: November 03 2007 at 16:52 | IP Logged Quote kemaa

Back to no return value. Do I need to include the & #176; (without the space) or just °. They seem to equal the same thing. I wrote it in my code as the first one but when I posted it online it was converted to the degree symbol. Does the search string need to look like the html code it is parsing through or can it be some of the visual results instead?
Back to Top View kemaa's Profile Search for other posts by kemaa
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: November 03 2007 at 18:47 | IP Logged Quote TonyNo

Dangit. The board changed the & #176; to a degree symbol. Yes, it should look just like the HTML code.

Browse to that page, view the source of the page, then search for that first section (<tr><td>Temperature</td>) and make sure it's even in there. Your ZIP may be getting different code.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
kemaa
Newbie
Newbie


Joined: October 17 2007
Online Status: Offline
Posts: 18
Posted: November 04 2007 at 17:27 | IP Logged Quote kemaa

I finally got it to work. Thanks a bunch! I'll be playing around with this now that I know it can work for me.
Back to Top View kemaa's Profile Search for other posts by kemaa
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum