Jump to content
Macro Express Forums

Write to file?


rberq

Recommended Posts

Two questions:

1) Is there a way to write directly to a text file with ME? I'm looking for the opposite of ASCII File Begin Process or Text File Begin Process. I can't seem to find any such command, but hoping I am just overlooking it....

2) How big can a string variable be?

Link to comment
Share on other sites

Two questions:

1) Is there a way to write directly to a text file with ME? I'm looking for the opposite of ASCII File Begin Process or Text File Begin Process. I can't seem to find any such command, but hoping I am just overlooking it....

2) How big can a string variable be?

 

You can use Modify Variable String to Save or Append to a text file (Save to create a new file, Append to add to an existing one).

 

If you're appending a list, you will want to make sure the last item appended per line has "Add Trailing CR/LF" checked. I mention this because you said you are looking for the opposite of an ASCII File Begin Process, where each item from the delimited file will be assigned to different variable by increments, so if you want the opposite, I imagine you may want to have multiple variables added per line.

 

Example:

Text file: "My Sons Sports.txt"

 

John, Baseball

Jim, Basketball

Terry, Football

 

ASCII File Process will assign John to %T1% (for example), Baseball to %T2%, then on its next pass, Jim gets %T1% and Basketball gets %T2%, etc.

 

The opposite, adding my nephews to the list, I'll use Modify String Variables to append to the text file, setting %T1% as "Corbin", %T2% as Soccer, then appending %T1% to the file, followed by %T2%, and when I append %T2% I will Add Trailing CR/LF so that when I do the next %T1% (Garrett), it will be on the line below Corbin, rather than on the same line and following Soccer.

 

Also, you'll want to append necessary separators to each variable that you're adding (such as a comma and space, as in my example below - this may not be necessary if you are appending to a Comma Delimited Text File AKA a .csv).

 

Here's my example:

 

Variable Set String %T1% from Prompt
Variable Modify String: Append ", " to %T1%
Variable Set String %T2% from Prompt
Variable Modify String: Append %T1% to Text File
Variable Modify String: Append %T2% to Text File

 

<TVAR2:01:02:FWho?FFCenter:Center><TMVAR2:07:01:00:000:000:, ><TVAR2:02:02:FWhich Sport?FFCenter:Center><TMVAR2:20:01:00:000:000:C:\Users\Steven\Documents\Macros\Macro Test Files\My Sons Sports For rberq.txtF><TMVAR2:20:02:00:000:000:C:\Users\Steven\Documents\Macros\Macro Test Files\My Sons Sports For rberq.txtT>

Link to comment
Share on other sites

Thank you, Steve, that's just what I needed to know. You must be a mind reader, because you anticipated exactly what I want to do -- write several variables per line, separated by commas, with cr/lf for each line.

 

P.S. Now I don't need to know how big a string variable can be, because I can write them out to disk as I build them. I was afraid I would have to accumulate thousands if short strings by appending them to a string variable, then "type" the whole thing into a Notepad file.

Link to comment
Share on other sites

Thank you, Steve, that's just what I needed to know. You must be a mind reader, because you anticipated exactly what I want to do -- write several variables per line, separated by commas, with cr/lf for each line.

 

P.S. Now I don't need to know how big a string variable can be, because I can write them out to disk as I build them. I was afraid I would have to accumulate thousands if short strings by appending them to a string variable, then "type" the whole thing into a Notepad file.

 

Yikes! I'm glad I could help you avoid that mess!

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