Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Help - macros / if statements !!! Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
ficklma1
Groupie
Groupie


Joined: December 08 2007
Location: United States
Online Status: Offline
Posts: 59
Posted: December 27 2007 at 23:08 | IP Logged Quote ficklma1

Please excuse my ignorance here

What am I doing wrong with this macro?

10 FORMULA if("[LOCAL7]" = "DINING3",
if("[LOCAL10]" = "0",
ph_run('C:\Program Files\xlobby\XReceive\xsend.exe ~~"command:xlobby:button state set:drlamps_toggle:Off~~"'),
ph_run('C:\Program Files\xlobby\XReceive\xsend.exe ~~"command:xlobby:button state set:drlamps_toggle:On~~"')))

I've been able to get one if to work, but when I add the nested if here: if("[LOCAL7]" = "DINING3", if("[LOCAL10]" = "0", true part, false part, etc.

It doesn't seem to do anything.

Also,
What's the correct macro type when trying to nest if statements? Jump, Formula, etc.

I've been trying to understand the "Jump" type, could someone explain this as well.

Please help.

Thanks

Edited by ficklma1 - December 27 2007 at 23:08
Back to Top View ficklma1's Profile Search for other posts by ficklma1
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: December 28 2007 at 08:02 | IP Logged Quote TonyNo

Unless the board chopped it off, I think you are just missing a comma. Try this...

Code:
10 FORMULA if("[LOCAL7]" = "DINING3", if("[LOCAL10]" = "0", ph_run('C:\Program Files\xlobby\XReceive\xsend.exe ~~"command:xlobby:button state set:drlamps_toggle:Off~~"'), ph_run('C:\Program Files\xlobby\XReceive\xsend.exe ~~"command:xlobby:button state set:drlamps_toggle:On~~"')), "")

For this, use a type of Formula.

JUMP transfers execution to the nth line after that one.

Example:
Code:
JUMP if([LOCAL1]=0, 1, 3)
USER MESSAGE "Jumped 1"
JUMP 999
USER MESSAGE "Jumped 3"


A JUMP value that is greater than the number of lines in a macro will exit that macro.

Edited by TonyNo - December 28 2007 at 08:03
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
cmhardwick
Senior Member
Senior Member
Avatar

Joined: July 08 2006
Location: United States
Online Status: Offline
Posts: 290
Posted: December 28 2007 at 08:25 | IP Logged Quote cmhardwick

Tony,

You can also put this in a GOTO LABEL type, as I do, to control program flow . I have it check if it's the device I want, if not, go to the next section and check there, if not, go to the next section, etc. Easier than jump because you can add lines and not have to refigure all your jump statements.

__________________
Cicero, Enjoying automation!
Back to Top View cmhardwick's Profile Search for other posts by cmhardwick Visit cmhardwick's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: December 28 2007 at 10:32 | IP Logged Quote TonyNo

Absolutely. I actually started replying about labels, but then noticed he was asking about JUMP, not GOTO LABEL.

As you say, labels are powerful.

Code:
GOTO LABEL if([LOCAL1]=0, "A", "B")
LABEL A
USER MESSAGE "Jumped to A"
JUMP 999
LABEL B
USER MESSAGE "Jumped to B"

Note that there are no quotes used for the LABEL definition.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: December 28 2007 at 13:58 | IP Logged Quote onhiatus

Oops, this was cross posted to Bugs - I anwered the above there. If anyone cares it is here - but basically it says the same thing...
Back to Top View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
ficklma1
Groupie
Groupie


Joined: December 08 2007
Location: United States
Online Status: Offline
Posts: 59
Posted: December 28 2007 at 17:30 | IP Logged Quote ficklma1

Thanks everyone!

I appreciate the help.

I renamed my xlobby button_id's to match my PH id's and I'm now passing the [LOCAL7] in the following if statement:

if("[LOCAL10]" = "0", ph_run('C:\Program Files\xlobby\XReceive\xsend.exe ~~"command:xlobby:button state set:[LOCAL7]_toggle:Off~~"'))

with this one if statement, I'm able to have it toggle all my xlobby buttons when the Insteon Device Chg trigger fires.

Thanks again for the great explanations.

Back to Top View ficklma1's Profile Search for other posts by ficklma1
 
cmhardwick
Senior Member
Senior Member
Avatar

Joined: July 08 2006
Location: United States
Online Status: Offline
Posts: 290
Posted: December 28 2007 at 20:00 | IP Logged Quote cmhardwick

Great idea on matching the button IDs. I'll have to look into that as well.

__________________
Cicero, Enjoying automation!
Back to Top View cmhardwick's Profile Search for other posts by cmhardwick Visit cmhardwick'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