Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: ph_regexdiff Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
mustangcoupe
Super User
Super User
Avatar

Joined: August 08 2003
Location: United States
Online Status: Offline
Posts: 308
Posted: May 15 2006 at 18:27 | IP Logged Quote mustangcoupe

I am trying to pull data from a web page, and need help... I am leaving in less then 12 hrs and i need to be able to check the water level in my basement.

the data is in a table looking like this
<TR><TD width=200>Probe 16:</TD><TD>-99.9</TD></TR>

I need to pull out the value -99.9 (it will change # depending on if the sensor is wet -99.9 is dry) then email my cell if it is wet. I thought I had it but I dont.... please help

__________________
Todd Hannemann

HA newbie

   PowerHome - UPB - ELK    
Back to Top View mustangcoupe's Profile Search for other posts by mustangcoupe Visit mustangcoupe's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: May 15 2006 at 19:32 | IP Logged Quote TonyNo

One version you can use is...

ph_regexdiff( "Probe 16:</TD><TD>","</TD>","[LOCAL1]",1,0)

Assuming that you pull the page into LOCAL1.

Tony
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
mustangcoupe
Super User
Super User
Avatar

Joined: August 08 2003
Location: United States
Online Status: Offline
Posts: 308
Posted: May 15 2006 at 21:25 | IP Logged Quote mustangcoupe

thats what I thought Tony
I had.........
ph_regexdiff("<TR><TD width=200>Probe 1:</TD><TD>","</TD></TR>","[LOCAL1]",1,0)

so I tried yours also....
[LOCAL1] = ph_geturl("http://192.168.10.99")

[LOCAL2] = ph_regexdiff( "Probe 1:</TD><TD>","</TD>","[LOCAL1]",1,0)

set GV [basement] = if([LOCAL2]="-99.9","Dry","Wet")

msgbox = [local2]

evaluates to !   

__________________
Todd Hannemann

HA newbie

   PowerHome - UPB - ELK    
Back to Top View mustangcoupe's Profile Search for other posts by mustangcoupe Visit mustangcoupe's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 15 2006 at 22:27 | IP Logged Quote dhoward

Todd,

Try using the ph_getvar_s(1,1) instead of the GV substitution "[LOCAL1]". If the the returned web page has any double quotes like HTML is prone to do, then the substitution will fail.

So, make the code look like this:

Code:

LOCAL1] = ph_geturl("http://192.168.10.99")
[LOCAL2] = ph_regexdiff( "Probe 1:</TD><TD>","</TD>",ph_getvar_s(1,1),1,0)


The other thing I see that may cause you problems is that in your first post you had "Probe 16" but in your other posts you have "Probe 1".

I got your PM so I assume it's with this problem. Let me know if this works or not for you.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: May 15 2006 at 22:43 | IP Logged Quote TonyNo

Ooh. Interesting.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
mustangcoupe
Super User
Super User
Avatar

Joined: August 08 2003
Location: United States
Online Status: Offline
Posts: 308
Posted: May 16 2006 at 06:33 | IP Logged Quote mustangcoupe

Sorry for the confision Dave I used probe 16 in the example, but probe 1 is the one actually connected... (it has 16 ports)

That does not fix it... I will have to just vnc in to the ph box and then check the internal webpage from the device while I am gone. I would like to get this working though. and Yes this is what the PM was about I thought you were still online when I signed in, but the database must not have refreshed yet... just missed you

__________________
Todd Hannemann

HA newbie

   PowerHome - UPB - ELK    
Back to Top View mustangcoupe's Profile Search for other posts by mustangcoupe Visit mustangcoupe's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 17 2006 at 20:46 | IP Logged Quote dhoward

Todd,

When you say it didnt work, do you mean that it didnt produce the desired results or did the formula fail with an "!"?

Let me know when you get back and we should be able to get it working.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
mustangcoupe
Super User
Super User
Avatar

Joined: August 08 2003
Location: United States
Online Status: Offline
Posts: 308
Posted: May 17 2006 at 23:19 | IP Logged Quote mustangcoupe

Yes dave, it does fail with the !

I will be home this weekend. I hear the rain stopped and I am (my basement is) still dry.....

__________________
Todd Hannemann

HA newbie

   PowerHome - UPB - ELK    
Back to Top View mustangcoupe's Profile Search for other posts by mustangcoupe Visit mustangcoupe's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 18 2006 at 14:42 | IP Logged Quote dhoward

Todd,

I just tested this on my end and it worked. So there must be something unique on your system that Im not replicating in my test environment.

Let me know when you get home and we'll get to work on it. It may require you to export the macro for me to import so I can test exactly what you're using.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
mustangcoupe
Super User
Super User
Avatar

Joined: August 08 2003
Location: United States
Online Status: Offline
Posts: 308
Posted: May 19 2006 at 09:41 | IP Logged Quote mustangcoupe

Dave,

I am home (well at work) I will send you an email with an IP address (I will open my firewall to a port for you)and a copy of the macro.
But I also have other problems running the get weather macro but I thought that was because of a change to their page.... hmmm.... interesting


__________________
Todd Hannemann

HA newbie

   PowerHome - UPB - ELK    
Back to Top View mustangcoupe's Profile Search for other posts by mustangcoupe Visit mustangcoupe's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 19 2006 at 13:02 | IP Logged Quote dhoward

No problem. Just let me know and we'll get it figured out.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
mustangcoupe
Super User
Super User
Avatar

Joined: August 08 2003
Location: United States
Online Status: Offline
Posts: 308
Posted: May 20 2006 at 08:49 | IP Logged Quote mustangcoupe

Dave I emailed you my IP/Port and my current macro.

Thanks

__________________
Todd Hannemann

HA newbie

   PowerHome - UPB - ELK    
Back to Top View mustangcoupe's Profile Search for other posts by mustangcoupe Visit mustangcoupe's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 22 2006 at 22:05 | IP Logged Quote dhoward

Todd,

Sorry to take so long getting back.

Ive imported your macro and hit the web page and found the problem. The problem was not in the ph_regexdiff but in the line below where you assigned the GV BASEMENT to a formula:

Code:
if([LOCAL2]="-99.9","Dry","Wet")


The problem lies in variable substitution. You're substituting [LOCAL2] which should contain a number and comparing it to a string. This is where the problem is. Variable substitution actually performs a simple search and replace. The [LOCAL2] will actually be replaced with whats in the variable and your formula will look like:

Code:
if(-99.9="-99.9","Dry","Wet")


You can see the number being compared to a string which will result in the BASEMENT GV being set to "!". In order to make this work, you must compare either numbers to numbers or strings to strings. So you could do this:

Code:
if("[LOCAL2]" = "-99.9","Dry","Wet")


or this:

Code:
if([LOCAL2] = - 99.9,"Dry","Wet")


You should also correct the last line where you have a messagebox and change [local2] to [LOCAL2]. Case is important. I would also probably put quotes around [LOCAL2] to make it a string just in case somehow an error occured and a number was not read in. With a string, you can display both a number or alphanumeric.

Hope this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
mustangcoupe
Super User
Super User
Avatar

Joined: August 08 2003
Location: United States
Online Status: Offline
Posts: 308
Posted: May 23 2006 at 07:21 | IP Logged Quote mustangcoupe

Thanks Dave, that works great.... The last line was just there for debug I am now setting up a smtp line to email my cell phone...

__________________
Todd Hannemann

HA newbie

   PowerHome - UPB - ELK    
Back to Top View mustangcoupe's Profile Search for other posts by mustangcoupe Visit mustangcoupe's Homepage
 

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