Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: ph_insteon cmd in IF statement Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
andyR
Newbie
Newbie


Joined: April 07 2010
Online Status: Offline
Posts: 15
Posted: October 30 2011 at 21:38 | IP Logged Quote andyR

I'm trying to get a 'ph_insteon' cmd run from inside an if statement, something like:

if(ph_fileexists("c:\powerhome\lights.on") = 1, ph_insteon("OUTSIDE LIGHTS",17,1), today())

Each of the parts of the statement are okay on their own (i.e. the if boolean check works, the ph_insteon works by itself, and the today() works, (which is just a default placeholder)) but I can't get them to work together. I think it has to do with the fact that the ph_insteon returns an integer and the IF statement wants strings (in fact, this works just fine if I use a different command like ph_getinsteondt("OUTSIDE LIGHTS") instead, so I don't think this is a syntax issue). I've tried putting a ph_rtne() or a string() around the ph_insteon command, but that doesn't seem to help. Any idea? Thanks a lot for any help.
Back to Top View andyR's Profile Search for other posts by andyR
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: October 30 2011 at 22:29 | IP Logged Quote dhoward

Andy,

You're close to the answer . The ph_insteon function returns an integer and the today() function returns a datetime. In order for the IF statement to work, both the true and false conditions MUST return the same datatype. String and string, number and number, etc. The below should fix it for you:

if(ph_fileexists("c:\powerhome\lights.on") = 1, ph_insteon("OUTSIDE LIGHTS",17,1),0)

Hope this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
andyR
Newbie
Newbie


Joined: April 07 2010
Online Status: Offline
Posts: 15
Posted: October 31 2011 at 22:29 | IP Logged Quote andyR

That makes sense. I feel dumb for not having tried that myself. Thank you very much for the quick reply.

andy
Back to Top View andyR's Profile Search for other posts by andyR
 

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