1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do you echo lines with special characters to file?

Discussion in 'Support' started by textparser, Jul 9, 2009.

  1. textparser

    Joined:
    Jul 4, 2009
    Messages:
    2
    Likes Received:
    0
    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. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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
     
  3. textparser

    Joined:
    Jul 4, 2009
    Messages:
    2
    Likes Received:
    0
    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. Roedy

    Joined:
    Jun 8, 2008
    Messages:
    120
    Likes Received:
    2
    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.
     
  5. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,307
    Likes Received:
    39
    You might also be interested in this:

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

Share This Page