Jump to content
Macro Express Forums

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:



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.



Link to comment
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%

Link to comment
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.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...