Variable Incrementing By 1 Problem - When 0 + 1 = 2

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
ljd0693
Newbie
Posts: 2
Joined: Mon Dec 03, 2007 7:29 pm

Variable Incrementing By 1 Problem - When 0 + 1 = 2

Post by ljd0693 » Mon Dec 03, 2007 7:48 pm

I'm currently having an extremely annoying math problem in my macro.

Below is the code that I'm using and the debug logging results when it gets to this section of code. I start off by setting the variable to zero then I add 1 to the variable. For some reason the macro thinks the value of the variable is initially 1 instead of zero. My loop always starts off at 2.

I've also tried using a Repeat loop but that also always starts at 2.

This loop is inside a subroutine that is called from within another Repeat loop but I used different variable names. This is the only section of code that has any reference to these variables.

I have similiar logic in a couple other places in my code and those sections work fine. This is the only part of the code is called from another repeat loop though.

If I have to, I'll try moving the code out of a subroutine and putting it directly inside the other repeat loop.

Any help will be appreciated. What are your thoughts?

I am using the latest version (9.2.01).


Let>ClickLoopCount=0
Label>BeginClickLoop
// Repeat>%ClickLoopCount%
Let>ClickLoopCount=%ClickLoopCount%+1
Let>ERPCP=ColorArray[%ClickLoopCount%]


12/3/2007 14:21:53:910 - START: Let>ClickLoopCount=0
12/3/2007 14:21:53:910 - END: Let>ClickLoopCount=0
12/3/2007 14:21:53:930 - START: Label>BeginClickLoop
12/3/2007 14:21:53:930 - END: Label>BeginClickLoop
12/3/2007 14:21:53:940 - START: // Repeat>1
12/3/2007 14:21:53:940 - END: // Repeat>1
12/3/2007 14:21:53:960 - START: Let>ClickLoopCount=1+1
12/3/2007 14:21:53:960 - END: Let>ClickLoopCount=2+1
12/3/2007 14:21:53:960 - START: Let>ERPCP=ColorArray[2]
12/3/2007 14:21:53:960 - END: Let>ERPCP=ColorArray[2]

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 03, 2007 8:40 pm

I suspect somewhere in your code you have inadvertently created a variable called 0 which is set to 1. Perhaps you have specified 0 as a return variable for some other command. You need to step through the code and keep an eye on the watch list. If 0=1 and ClickLoopCount is assigned the value of 0 then it will become 1.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

ljd0693
Newbie
Posts: 2
Joined: Mon Dec 03, 2007 7:29 pm

Post by ljd0693 » Mon Dec 03, 2007 10:41 pm

Hmm, interesting. I'll have to check that out.

You must be right because when I add the following line at the top of the subroutine it works correctly.

Let>0=1-1

Thanks for the quick reply! I never would have thought it possible to create a variable with a name of 0.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts