Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Macro Problem with Goto Label Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
GCollins
Groupie
Groupie
Avatar

Joined: March 27 2011
Location: United States
Online Status: Offline
Posts: 53
Posted: March 08 2015 at 19:16 | IP Logged Quote GCollins

I'm running PH v2.1.4. I'm having trouble with a conditional Goto Label statement in a macro. The exported macro follows:

insert into macroheader values ('MA-MOTION_ON','Front Motion On',0,0,1);
insert into macrodetail values ('MA-MOTION_ON',1,10,'DARK',NULL,'0',0,'','');
insert into macrodetail values ('MA-MOTION_ON',2,27,'',NULL,'if("{DARK}"="0", "END", "BEGIN")',0,'','');
insert into macrodetail values ('MA-MOTION_ON',3,26,'',NULL,'BEGIN',0,'','');
insert into macrodetail values ('MA-MOTION_ON',4,23,'80-FRONT-DOOR',2,'',0,'','');
insert into macrodetail values ('MA-MOTION_ON',5,23,'15-FOYER',2,'',0,'','');
insert into macrodetail values ('MA-MOTION_ON',6,26,'',NULL,'END',0,'','');

In the first macro statement (2nd line above) I'm doing a Set Global {DARK} = 0 for testing purposes. In the second statement I'm doing a Goto Label with the following in the Formula | TTS |Dim
column:

if("{DARK}"="0", "END", "BEGIN")

The next statement is a Label named BEGIN, then there are some X10 commands and finally a Label called END.

After playing the macro at least once the Check Formula tool properly returns "The formula evaluates to END". However, playing the macro falls straight through and executes each line.

What am I doing wrong?

Thanks,
Gregg

Back to Top View GCollins's Profile Search for other posts by GCollins
 
GCollins
Groupie
Groupie
Avatar

Joined: March 27 2011
Location: United States
Online Status: Offline
Posts: 53
Posted: March 08 2015 at 20:37 | IP Logged Quote GCollins

FWIW, same problem after upgrading to v2.1.5c.

That said, for this particular task I've opted to take the more efficient approach of moving the logic to the Boolean column of the trigger
that launches this macro. eg: if("{DARK}"="0", 0, 1)

I'd still like to understand what I'm doing wrong with the macro, though.

Thanks
Back to Top View GCollins's Profile Search for other posts by GCollins
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: March 09 2015 at 23:27 | IP Logged Quote dhoward

GC,

I imported your macro and tested on my system and it
worked fine for me. I changed the first line back and
forth between 1 and 0 and then run the macro and could
not get it to fail. I also added a message box command
just after the BEGIN label to determine when hit that
label or not.

I tried to figure out a couple of ways to make it fail
and was only able to if I deleted (or renamed) the
DARK global variable in the Global Variables screen.
With that change, then it would always hit the BEGIN
label and execute the macro no matter what value was
assigned to DARK.

I cant see anything you're doing wrong from this end.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
GCollins
Groupie
Groupie
Avatar

Joined: March 27 2011
Location: United States
Online Status: Offline
Posts: 53
Posted: March 10 2015 at 10:16 | IP Logged Quote GCollins

Dave,

Thanks for taking the time to test my macro!

I've gone back to it this morning and am driving
myself crazy with different variations trying to get
it to work. I cannot. I've tried deleting/recreating
the global variable, changing the name of the
variable, deleting/recreating the Goto Label
statement, changing variable values, using quotes
around it or not, etc., etc. It just falls straight
thru every time.

A positive sign is that no matter what I set the
variable to in the macro, this is reflected in the
Global Variables screen afterwards.

Maybe I'm just doing something really dumb, but I sure
am stumped. I wish I could show you a screen shot,
but the forum won't let me upload images. Maybe that
has to do with my newbie status. Can you upgrade me?

Thanks
Back to Top View GCollins's Profile Search for other posts by GCollins
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: March 11 2015 at 21:48 | IP Logged Quote dhoward

G,

Nothing to upgrade...image uploading should be active
for all users. It is problematic though and seems to
work better with certain browsers (Chrome seems to
have a problem). In any event, you can always email me
a screenshot direct.

Just wondering how you're able to tell when the macro
terminates early vs playing all the way through. Are
you using a messagebox, user message, or some other
mechanism to tell which lines in the macro are
actually being executed?

Let me know,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
GCollins
Groupie
Groupie
Avatar

Joined: March 27 2011
Location: United States
Online Status: Offline
Posts: 53
Posted: March 15 2015 at 22:01 | IP Logged Quote GCollins

Hi Dave,

I was just watching a light, but then added a message box.

Was using Chrome, but can't upload w/ Firefox either so will email.

I keep tinkering with syntax or char/numeric issue, but still banging head...

Thanks,
G


Back to Top View GCollins's Profile Search for other posts by GCollins
 

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