Jump to content
Macro Express Forums

Parsing To A Specific Row Of A Text File


Teoman

Recommended Posts

I am new to Macro Express, and maybe my question has a very "naive" nature.

I have a template text file "temp.txt" and want to parse a specific string, let say "writeme", to specific rows of the "temp.txt" file, say "10,20,30"

 

I set the string variable "T1" to "writeme". But I could not find a way to parse T1 value to those rows.

 

Is there any suggestion for that ?

 

Thanks

 

Teoman

Link to comment
Share on other sites

Hello Teoman!

 

I think you are saying that you want to insert "writeme" after each 10th line in the target text file. To do this you will need to use the Process Text File, Append to Text String, and Save Text String to File commands.

 

You first need to count the lines and then divide by 10. The result is how many times you will need to loop because you are inserting at every 10th line. Set up a Repeat Loop from 1 to whatever the number is and increment by 10 each time. Use the Process Text File construct inside the loop. The line you want to start with is your counter. The number of lines to process is 10. Within this construct, append the next text line and a CR/LF to a fixed text variable, say %T10%. Essentially you are reading the text file into a variable one line at a time.

 

Place an Append to Text String command after the End Text Process command. The text to append is "writeme" plus a CR/LF.

 

At the end of the Repeat Loop, you will want to process the remaining lines so they too are appended to your fixed string. After that, just write the fixed string back to a text file.

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.

Guest
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.

Loading...
×
×
  • Create New...