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


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: February 23 2008 at 13:12 | IP Logged Quote jeffw_00

Hi-

1) I find myself coding a lot of

GOTO_LABEL if (<condition>,LABEL1,LABEL2)
LABEL2
code continues...

I'd really like a way to code
GOTO_LABEL if (<condition>,LABEL1)

and if the condition fails, fall through to the next line. Is there a way to do this?

2) I've been playing with ph_insteonwithret but I don't seem to be able to get a return value. Here's what I'm doing...

ph_setvar_a(1,9,ph_insteonwithret("[LOCAL1]","[LOCAL6]",0))
LOCAL1 = an insteon ID
LOCAL2 = 18 or 20

but after this is executed, LOCAL9 is blank.

3) is there a way to AND conditions? I.e., if (and(<condition1>,<condition2>),x,y)

I saw the ph_and function but not sure this is a valid use of it.

Thanks
/j

PS - Extra credit... is there an argument for GOTO_LABEL that is the equivalent of JUMP 999 (I.e.,
GOTO_LABEL (if(condition),"CONTINUE","EXIT")

where EXIT is like a jump 999?
thx again
/j

Edited by jeffw_00 - February 23 2008 at 14:25
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: February 23 2008 at 14:02 | IP Logged Quote BeachBum

This may sound funky but I basically NOP the JUMP by using an invalid label. As far as question 3 wouldn't using a + do the AND function for you or am I in the wrong ball park...

Edited by BeachBum - February 23 2008 at 14:02


__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: February 23 2008 at 14:05 | IP Logged Quote jeffw_00

Beachbum - can you give me an example of your invalid label. Do you just use a "FOO" that's undefined?

+ is a concatenate function, what I'm going for is

if (condition1 is true AND condition2 is true, dothis, otherwise-do-this)

thanks
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: February 23 2008 at 14:18 | IP Logged Quote BeachBum

Sure.. IF (PH_GETGLOBAL_S(PH_GETGLOBAL_S("LEVEL_GLOBAL")) = " ", "NEXT", "NOP")
… Not true goes to here
…
JUMP     “END”
Label NEXT   True jumps to here.

IF.. I'll check but I think I do that somewhere.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: February 23 2008 at 14:25 | IP Logged Quote jeffw_00

yup that works...
Now, i wish there was an argument for GOTO_LABEL that was the equivalent of JUMP 999 (I.e.,
GOTO_LABEL (if(condition),"CONTINUE","EXIT")

where EXIT is like a jump 999.

am I in luck? 8-}
thanks
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: February 23 2008 at 14:30 | IP Logged Quote BeachBum

Next one..

Is this an example of what you are looking for?

IF (PH_GETGLOBAL_S ( "MBR_TV_CHECK" ) = "OFF" AND ( NOW() < 07:58:00) AND (NOW() > RELATIVETIME( 00:00:00, [SUNSET] - 3600 )), 999, 1)

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: February 23 2008 at 14:40 | IP Logged Quote jeffw_00

yup - that answers qn 3.
thanks
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: February 23 2008 at 15:07 | IP Logged Quote BeachBum

Question 2:
When I SET SYSTEM    LOCAL9      ph_insteonwithret ( "kitchen", 17, 200 )    I get a return of 200 in LOCAL9. Maybe this will help you zero in on the problem.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: February 23 2008 at 15:17 | IP Logged Quote jeffw_00

yeah - the problem was the 2nd argument had to be a number, replacing "[LOCAL6]" with ph_getvar_n(1,6) fixed it. so this works...

ph_setvar_a(1,9,ph_insteonwithret("[LOCAL1]",ph_getvar_n(1,6),0))

thanks
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: February 23 2008 at 15:20 | IP Logged Quote BeachBum

   Well good.. I'm on the way to the beach since it's hovering around 70.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: February 23 2008 at 18:47 | IP Logged Quote jeffw_00

it's around 20F here, which is why I'm messing with PH this afternoon 8-}
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: February 23 2008 at 20:34 | IP Logged Quote dhoward

Whoa, I was way too slow on this one.

Yep, if a label doesnt actually exist in a Goto Label command, control just transfers to the next line. So you can do this:

Goto Label if(1 = 0,"LOOP1","")

and control will just transfer to the next line as long as you don't have a blank label.

No equivalent of a Jump 999 with labels. However it's very easy to setup and something I do all the time. Just make your very last statement of the macro a label with a value of "END". Then just use the END anytime you want to exit the macro.

The ph_and function is a bitwise and function. So ph_and(4,2) will 0. Similarly, ph_or is a bitwise or function. ph_or(4,2) will equal 6. Logical AND and OR just uses the word AND and OR. So (1 = 1) and (2 = 2) will be true.

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


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: February 23 2008 at 20:36 | IP Logged Quote jeffw_00

thanks dave - I figured out the "END" thing, figured it couldn't hurt to ask about something cleaner. It's a nit though. However, the dropthrough (null label) helps a lot for code cleanliness
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: February 23 2008 at 20:45 | IP Logged Quote BeachBum

   Thks Dave...

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 

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