How do you echo lines with special characters to file?

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Jul 4, 2009
2
0
#1
I grab a line from a text file to a variable and output it to another. Example: DO line IN @file1.txt echo %line >> file2.txt ENDDO It has a problem: special characters like " ` < > | and long lines (is there a variable length limit?) are not appended to the file but are printed on screen. How do make it do the job properly (like it does when the lines aren't too long and don't contain special characters)? As a workaround, I'm replacing all occurrences of special characters, like " with ---doublequote---, and then replacing them back to original when the echoing is done. If this is the only way, how would I do that for all special characters in a whole file? Got code? Now I'm doing it manually in text editor, and perhaps will record a macro for it. How do I remove the appended lines from the original file?
 
#2
textparser wrote:
| I grab a line from a text file to a variable and output it to
| another. Example: DO line IN @file1.txt echo %line >> file2.txt
| ENDDO It has a problem: special characters like " ` < > | and long
| lines (is there a variable length limit?) are not appended to the
| file but are printed on screen. How do make it do the job properly
| (like it does when the lines aren't too long and don't contain
| special characters)? As a workaround, I'm replacing all occurrences
| of special characters, like " with ---doublequote---, and then
| replacing them back to original when the echoing is done. If this
| is the only way, how would I do that for all special characters in a
| whole file? Got code? Now I'm doing it manually in text editor, and
| perhaps will record a macro for it.

That's what the new feature in V10: binary buffers were invented for. Look
at the functions @B...!
--
HTH, Steve
 
Jul 4, 2009
2
0
#3
I'm unfamiliar with those. How would you do the equivalent of what I did, with @B...? How do you delete the lines from the original after appending them to a new file?
 
#4
I grab a line from a text file to a variable and output it to another. Example: DO line IN @file1.txt echo %line >> file2.txt ENDDO It has a problem: special characters like " ` < > | and long lines (is there a variable length limit?) are not appended to the file but are printed on screen. How do make it do the job properly (like it does when the lines aren't too long and don't contain special characters)?
see http://mindprod.com/products.html#SAY!
includes MASM and C versions if you want to compose a short string containing control chars and special chars and redirect it to a file.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,385
39
Albuquerque, NM
prospero.unm.edu
#5
I grab a line from a text file to a variable and output it to another. Example: DO line IN @file1.txt echo %line >> file2.txt ENDDO It has a problem: special characters like " ` < > | and long lines (is there a variable length limit?) are not appended to the file but are printed on screen. How do make it do the job properly (like it does when the lines aren't too long and don't contain special characters)? As a workaround, I'm replacing all occurrences of special characters, like " with ---doublequote---, and then replacing them back to original when the echoing is done. If this is the only way, how would I do that for all special characters in a whole file? Got code? Now I'm doing it manually in text editor, and perhaps will record a macro for it. How do I remove the appended lines from the original file?
You might also be interested in this:

http://www.unm.edu/~cdye/plugins/safechars.html