Author |
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: June 29 2013 at 12:21 | IP Logged
|
|
|
I'm using the ph_regexsnap PH function to parse the Wind
Speed data off a weather site to use in my home
environmental CC report.
Unfortunately occasionally the web site omits the Wind
Speed and then regxsnap returns a null string to
[LOCAL3].
This always causes fatal syntax errors in subsequent
calculation formulas.
I have not been able to discover a method to detect and
correct this issue, however, as "IsNull" and "IsNumber"
testing on [LOCAL3} tests also fails with a syntax error.
Is there a method to detect this empty [LOCAL3] so I can
populate it with the last good data before doing follow-
on calculations?
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: July 01 2013 at 19:26 | IP Logged
|
|
|
Did you try to compare it to ""?
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: July 02 2013 at 06:02 | IP Logged
|
|
|
Yes.
Sorry, I forgot to put that in my post. Comparing to ""
was actually the first thing I tried.
I'm really stumped by this one, as I've never encountered
this kind of quirk.
I wonder if ph_regexsnap just throws off some wierd value
when it doesn't get a match that then puts a wrench in
follow-on code?
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: July 02 2013 at 08:25 | IP Logged
|
|
|
What about assigning [LOCAL3] equal to " " before calling the web site that does not return Wind Speed. If [LOCAL3] is not being set because Wind Speed is missing perhaps pre-assigning some value would at least make the variable accessible. Just a SWAG.
__________________ Lee G
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: July 02 2013 at 16:20 | IP Logged
|
|
|
Hum Lee -
Interesting suggestion. I'll give it a try and we'll see
what happens.
Will report back (but it sometimes is many weeks between
errors).
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: July 06 2013 at 19:48 | IP Logged
|
|
|
Didn't work. I still have gotten errors.
This doesn't seem right. There must be a way to test for
valid data, or not, to prevent Syntax errors.
Dave - what am I overlooking?
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
gg102 Senior Member
Joined: January 29 2013 Location: United States
Online Status: Offline Posts: 245
|
Posted: July 22 2013 at 19:47 | IP Logged
|
|
|
Have you tried LEN ?
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: July 23 2013 at 15:22 | IP Logged
|
|
|
Thanks gg102 for your suggestion. Yes, in fact LEN was
the only way I could make it work and then Dave advised
the following, which TOTALLY solved the problem.
Quote:
-- Dave Howard --
The main problem you're having with null values is their
limitations with variable substitution. You should ONLY
use variable substitution when you KNOW the value in the
variable is what you expect. If you're unsure of the
data in variable, you should use the ph_getvar_?
functions to retrieve the variable with the datatype your
formula requires. So instead of:
ph_msgbox("","[LOCAL3]",0)
you would use:
ph_msgbox("",ph_getvar_s(1,3),0)
This would return the value in [LOCAL3] as a string no
matter what the data it contains (including null). You
should then be able to compare it to an empty string
(""). If you prefer to use variable substitution, you
can use something like this to force a proper value into
the variable after retrieving unknown data:
ph_setvar_s(1,3,ph_getvar_s(1,3))
|
|
|
As always, Dave "nailed it"
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|