Results 1 to 5 of 5

Thread: Replacing text in open ascii file

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 1999
    Location
    Milford, NH
    Posts
    15

    Post

    What is the comand to replace text in an open ascii file? Please help.

  2. #2
    New Member
    Join Date
    Jul 1999
    Posts
    15

    Post

    Originally posted by JohnL55:
    What is the comand to replace text in an open ascii file? Please help.
    Read your text into a string variable or array whichever best suits your needs and then use instr to find each instance of the text you want to replace. Then use mid$ to replace the text and write it back out to the file.

    [This message has been edited by Lemp (edited 02-03-2000).]

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Post

    The mid() function can be a little combersome for lots of replacements especially if you're replacing the same text (like in a multi find replace program )
    read to a string then use the replace function.

    FileString = Replace(FileString, OldText, NewText)

    For some reason this function is not that well known



  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 1999
    Location
    Milford, NH
    Posts
    15

    Post

    Originally posted by Paul282:
    The mid() function can be a little combersome for lots of replacements especially if you're replacing the same text (like in a multi find replace program )
    read to a string then use the replace function.

    FileString = Replace(FileString, OldText, NewText)

    For some reason this function is not that well known

    When writing FileString back to the document, double quotes are added to the start and end of the string. The double quotes are not in the string to start with.
    Take the words NEW DATA. When I write it back, it comes out "NEW DATA". If I replace in the string the Quotes with nothing it does not get rid of the quotes because they are not really in the string.

  5. #5
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    It depends on what you use to write the string back to the doc. If you use print it just plain dumps it, if you use write it puts quotes around things. If you look up the Write function it mentions that. That's how I get around it. Write is convienant when writing to a CSV but I use the Print one more often.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width