Repeat statement not working.

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
suthek
Newbie
Posts: 2
Joined: Thu May 24, 2012 7:40 pm

Repeat statement not working.

Post by suthek » Thu May 24, 2012 7:46 pm

I went into the help and grabbed the example repeat until statement.
Let>k=0
Repeat>k
Let>k=k+1
Message>file_names_%k%
Until>k,2

(changed the last var to a constant of 2 for testing)

I pasted it into the code window to see if even it would work and it doesnt.

I noticed that when I say %k% it types "k+1"
I guess it's handling the k=k+1 as a string instead of a math question.

Am I missing something to fix this?

Thanks for your help.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu May 24, 2012 8:49 pm

I noticed that when I say %k% it types "k+1"
I don't know what you mean by this.

Try these steps.

- Open the editor and paste in the code you have posted.
- Make sure there are no trailing spaces. I had one after the Until>k,2
- Make sure you place some blank lines after the last line
- Go to the "Tools" menu and make sure "Show Builder Pane" is checked
- Place the cursor at the top of the script, anywhere on the first line.
- Press the F8 key. F8 steps through the code one line at a time
- The builder pane on the left should now be displaying the "Watch List" where you can witness the variables as they change.
- The script should work flawlessly and you will be able to watch each step of the process.

suthek
Newbie
Posts: 2
Joined: Thu May 24, 2012 7:40 pm

Post by suthek » Fri May 25, 2012 4:01 am

This is my code below.
It doesn't stop after two loops.
and when I do "Send>%k%" it types "k+1"
there are no spaces that I can see?

CapsOff
Let>k=0
repeat>k
Let>k=k+1
MouseMove>1339,454
Wait>0.01
LClick
Wait>0.01
Press Backspace * 10
Wait>0.01
Send>2
Send>0
Random>9,DiceResult
Send>%DiceResult%
Random>9,DiceResult
Send>%DiceResult%
Random>9,DiceResult
Send>%DiceResult%
Wait>0.1
MouseMove>1293,491
Wait>0.01
LClick
Wait>3.41
MouseMove>1800,210
Until>k,2

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Fri May 25, 2012 3:20 pm

I don't have any problems with the code you posted. It sends 1 then 2 and then stops.

Which version of Macro Scheduler do you have?
Is that the entire script or just a portion of it? If it's a portion, can you post the entire script?

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Repeat statement not working.

Post by mightycpa » Tue Oct 14, 2014 2:19 pm

Hi,

I'm appending to this old thread because I notice it never got answered. I have the same problem.

I'm now having a similar problem, also connected to a repeat. Am I just doing something stupid?

T does not get evaluated as a number, only as a string. I've tried % around the "k" and "e", and watching it in the debugger shows that it is clearly a string, pretty much no matter what I try.

As a result, the wait function doesn't work. Version 14.1.04 on Windows 7 Professional.

Code: Select all

MouseMove>850,-150
Let>e=575
Let>k=850
Let>t=(k-e)/1000
//MessageModal>%t%
Repeat>k
  Let>k=k-1
  MouseMove>%k%,-150
  Wait>t
Until>k=e
 
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Repeat statement not working. SOLVED!

Post by mightycpa » Tue Oct 14, 2014 2:38 pm

I guess the answer is to do the math in two steps:

this yields a string:

Code: Select all

Let>t=(k-e)/1000
this yields a number:

Code: Select all

Let>t=%k%-%e%
Let>t=t/1000
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

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

Re: Repeat statement not working.

Post by Marcus Tettmar » Tue Oct 14, 2014 2:48 pm

You need to do:

Let>t={(%k%-%e%)/1000}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Repeat statement not working.

Post by mightycpa » Tue Oct 14, 2014 3:22 pm

That did the trick, thanks.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

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