Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: Indirection, please... 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: December 01 2007 at 20:57 | IP Logged Quote jeffw_00

Ok - how do I do this.   8-}

I want to write a Jump formula like

if ( xxx = 1,1,3)

where xxx is the global variable whose NAME is passed by [LOCAL1]

so [LOCAL1] would be a STRING (line "BTNCNT"), and I want to branch on the VALUE of BTNCNT.

I've tried everything I could think of, but no luck....

Thanks!
/j
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: December 01 2007 at 21:14 | IP Logged Quote dhoward

Jeff,

I do this all of the time and find it a very powerful feature of PowerHome. Instead of the Jump statement, I use a "Goto Label" command. I set this up like this:

10 Goto Label XXX

where XXX is either a global or local variable in the form of {GLOBAL_ID}, ph_getglobal_s("GLOBAL_ID"), [LOCAL1], or ph_getvar_s(1,1).

Whatever string is contained within either the global or the local variable will be the "Label" line in the macro that will be jumped to. The great thing about this too is that if the label cant be found, ie. the value contained in the global or local does not match a corresponding label in the macro, PowerHome will just go to the next line following the Goto Label command (no errors).

HTH,

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: December 01 2007 at 21:37 | IP Logged Quote jeffw_00

Hi Dave - sorry, I don't quite follow. The value of the GLOBAL_VARIABLE whose name I am passing via LOCAL1 will be a 1 or a 0, and I don't want to goto 1, goto 0, or goto BTNCNT.

I want to branch on the value of the named GLOBAL_VARIABLE for which I have passed only the name, not its value.

I hate to ask again, but I don't see how to do what I'm suggesting from what you said.

I may be explaining myself poorly. Here's exactly what I'm doing:

MACRO_A:
ph_macroparm("MACRO_B","BTNPRS",0,0,0,0)

MACRO B:
Jump if({[LOCAL1]}=1,1,999)
           ^^^^^^^
I want the branch to be based on the -value- of global variable BTNPRS, which is one of many possible globals I might pass to MACRO_B.

what I need to know is how to express the variable underlined by ^^^^^^^^ so that it finds the value of the global variable whose name is [LOCAL1]

{[LOCAL1]} didn't work
{"[LOCAL1]"} didn't work
(ph_getvar_a(1,1)) didn't work
{(ph_getvar_a(1,1))} didn't work

and then I ran out of ideas.

Sorry if i'm being dense.

Thanks
/j



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: December 01 2007 at 22:25 | IP Logged Quote dhoward

Jeff,

Ok, I think I understand now. BTNPRS is the ID of a global variable and this global variable will contain either a 1 or 0. You'll pass the ID of the global into the called macro via [LOCAL1] in the ph_macroparm function.

Jump if(ph_getglobal_n(ph_getvar_s(1,1)) = 1, 1, 999)

should do the trick. You could also use variable substitution:

Jump if(ph_getglobal_n("[LOCAL1]") = 1, 1, 999)

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: December 01 2007 at 22:40 | IP Logged Quote jeffw_00

Hi Dave - Thanks - the first form gave me weird results, but the 2nd form (variable substitution) worked like a champ.

Thanks
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 

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