Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Bug Reports
 PowerHome Messageboard : PowerHome Bug Reports
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:03 | IP Logged Quote ficklma1

I've added this post to the programming section, posted it here by mistake.






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:10
Back to Top View ficklma1's Profile Search for other posts by ficklma1
 
onhiatus
Senior Member
Senior Member
Avatar

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

Could it be as simple as you are missing a "false part" for the first if statement? I don't have PH in front of me, but I don't think the false statement is optional.

So you want something like:

Code:
if("[LOCAL7>" = "DINING3",
   if("[LOCAL10>" = "0",
       ph_run('C:\...drla mps_to ggle:Off~~"')
   ,
       ph_run('C:\...drla mps_to ggle:On~~"')
   )

,
   ""

)



I tend to use GOTO instead of JUMP - this is because whith a jump statement you have to change the # of lines to skip when you insert new lines into the macro. Also the Labels do double duty as comments.

The trick with GOTO is that the label line is a string without quotes (E.g. LABEL, ... , The End), but when you reference it in a GOTO statement you have to quote it (E.g. GOTO, ... , "The End")

Often you use a formula with a JUMP or a GOTO to make a conditional jump. In that case you have a formula that resolves to a number (in the case of a JUMP) or a string (in the case of a GOTO. Something like:
Code:
   GOTO, if ("[LOCAL1>"="TRUE", "True Label", "False Label")
   JUMP, if ("[LOCAL1>"="TRUE", 1, 999)

Hope this helps.

Edited by onhiatus - December 28 2007 at 14:02
Back to Top View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus'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:56 | IP Logged Quote onhiatus

I had a slightly snarky comment about posting in the wrong place, but I just realized that I should have read your edit... my bad.


Edited by onhiatus - December 28 2007 at 13:59
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 22:42 | IP Logged Quote ficklma1

Thanks onhiatus...good explanations, I need all the help I can get.
Back to Top View ficklma1's Profile Search for other posts by ficklma1
 

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