| 
    
     | 
       
        | Author |  |  
        | andyR Newbie
 
  
 
 Joined: April 07 2010
 Online Status: Offline
 Posts: 15
 | 
          I'm trying to get a 'ph_insteon' cmd run from inside an if statement, something like:
           | Posted: October 30 2011 at 21:38 | IP Logged |   |  
           | 
 |  
 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 |     |  
        |  |  
        | dhoward Admin Group
 
  
  
 Joined: June 29 2001
 Location: United States
 Online Status: Offline
 Posts: 4447
 | 
          Andy,
           | Posted: October 30 2011 at 22:29 | IP Logged |   |  
           | 
 |  
 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 |       |  
        |  |  
        | andyR Newbie
 
  
 
 Joined: April 07 2010
 Online Status: Offline
 Posts: 15
 | 
          That makes sense.  I feel dumb for not having tried that myself.  Thank you very much for the quick reply.
           | Posted: October 31 2011 at 22:29 | IP Logged |   |  
           | 
 |  
 andy
 |  
        | Back to Top |     |  
        |  |  |  |