Jump to content
Macro Express Forums
prathimayellapragada

Regarding repeat loop

Recommended Posts

Hi All,

Can anyone help me with an answer, here is my question:

Basically I have a variable in a text file which is T1 which has a number of times loop must execute. Basically I want repeat loop each time to pick a different value in iteration, is it possible ?

My text file has:

4

5

I expect my repeat counter to repeat 4 times in first iteration and 5 times in second iteration, however I see that it is always considering 4 times. Can anyone help me on this please.

Thanks in advance.

 

InfoME.jpg

Share this post


Link to post
Share on other sites

It is more difficult to help because you posted a screen shot instead of an actual macro. A macro can be attached to posts in this forum. Here are a couple of things that I would change:

1. If your testdat.txt file contains only one item per line I would use the Text File Begin/End Process commands instead of the ASCII File Begin/End Process commands. But, the ASCII File Begin Process should work.

2. Either of those commands put the content of the testdat.txt file into a variable. It is not necessary to include this command:

  Variable Set String %T1% from File: "Testdat.txt"

3. You may want to move this line just below the ASCII File Begin Process command:

  Variable Set %N1% to ASCII value of %T1%

Share this post


Link to post
Share on other sites

You have a loop within a loop.  The outer loop is ASCII File Begin Process.  The inner loop is Repeat With Variable Using N1.

So yes, get rid of the line “Variable Set String %T1% from File: Testdat.txt"
because each time through ASCII File Begin Process the next line of your file will be loaded into T1, which is what you want.  Regardless of which line of the ASCII file has just been read, I think “Variable Set String %T1% from File” picks up the FIRST line all over again.  That would explain why it always repeats 4 times regardless of what the file contains in subsequent lines.  

Also, I would recommend converting from text to integer with command
Variable Modify String: Convert %T1% to integer %N1%
rather than
Variable Set %N1% to ASCII value of %T1%.  
In case %T1% contains blanks or newline/carriage-return characters, trim it before doing the conversion to integer.

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×