Loops not working (apparently)

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
machinogodzilla
Newbie
Posts: 17
Joined: Sun Jul 30, 2006 11:32 pm

Loops not working (apparently)

Post by machinogodzilla » Mon Aug 21, 2006 11:19 am

Hi! I am making a makro containg a part with loops. Unfortuantely they do not want to work properly. I checked everything and run out of ideas. Maybe you can help me.

Code: Select all


//===================The first loop

Let>c=0
Let>m=1
Repeat>m

		if>m=1,CheckNext1

		Let>XMax=100
		Let>YMax=100
		Let>X=98

		Repeat>X

				Let>X=X+1
				Let>Y=98

				Repeat>Y

						Let>Y=Y+1
						GetPixelColor>X,Y,c

						MessageModal>loop No 1, main loop repetition No= %m%

						If>c=456765,DoIt1,DontDoIt1

						Label>DoIt1
						MouseMove>X,Y
						LClick
						Wait>0.1
						MouseMove>%m%,%m%
						LClick
						Wait>0.5

						Label>DontDoIt1

				Until>Y=YMax

		Until>X=XMax

		Label>CheckNext1

Let>m=m+1
Until>m=5

//===================End - the first loop

//===================The second loop

Let>c=0
Let>m=1
Repeat>m

		if>m=2,CheckNext2

		Let>XMax=200
		Let>YMax=200
		Let>X=198

		Repeat>X

				Let>X=X+1
				Let>Y=198

				Repeat>Y

						Let>Y=Y+1
						GetPixelColor>X,Y,c

						MessageModal>loop No 2, main loop repetition No= %m%


						If>c=456786,DoIt2,DontDoIt2

						Label>DoIt2
						MouseMove>X,Y
						LClick
						Wait>0.1
						MouseMove>%m%,%m%
						LClick
						Wait>0.5

						Label>DontDoIt2

				Until>Y=YMax

		Until>X=XMax

		Label>CheckNext2

Let>m=m+1
Until>m=5

//===================End - the second loop

The messages SHOULD show:

"Loop No 1, main loop repetition No= 2" -> four times
"Loop No 1, main loop repetition No= 3" -> four times
"Loop No 1, main loop repetition No= 4" -> four times

"Loop No 2, main loop repetition No= 1" -> four times
"Loop No 2, main loop repetition No= 3" -> four times
"Loop No 2, main loop repetition No= 4" -> four times

"The End."


And what actually happens:

"Loop No 1, main loop repetition No= 2" -> four times
"Loop No 1, main loop repetition No= 3" -> four times
"Loop No 1, main loop repetition No= 4" -> four times

"Loop No 2, main loop repetition No= 1" -> one time

"Loop No 1, main loop repetition No= 1" -> several times

"Loop No 1, main loop repetition No= 2" -> four times
"Loop No 1, main loop repetition No= 3" -> four times
"Loop No 1, main loop repetition No= 4" -> four times

"Loop No 2, main loop repetition No= 1" -> one time

"Loop No 1, main loop repetition No= 1" -> several times

and so on......


The first loop appears to work properly. But when it comes to start the second one only the beginning is executed and then everything starts all over again with unexpected results. Why is that?

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

Post by Marcus Tettmar » Mon Aug 21, 2006 11:44 am

Which version are you using.

From http://www.mjtnet.com/mswhatsnew.htm
Version 8.0.2 09/05/2006
Repeat/Until no longer requires unique loop counter
Prior to 8.0.2 each Repeat/Until block required a unique loop counter variable. Otherwise Until looped back to the first Repeat with matching loop counter.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
machinogodzilla
Newbie
Posts: 17
Joined: Sun Jul 30, 2006 11:32 pm

Post by machinogodzilla » Mon Aug 21, 2006 12:10 pm

I was using 8.0.1 and have just downloaded 8.0.3. That is much better now :D

Thx!

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