Results 1 to 2 of 2

Thread: Updating a text file

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2000
    Posts
    38

    Unhappy

    I am trying to open a text file and read through each line. If the line begins with the specified string, I want to change it to read something different. I am able to open it and read each line okay, but I can't figure out how to do the updating. Can somebody please show me how?

    Thank you.

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    One way would be something like this pseudo-code

    1. Create a NewTextFile
    2. assign a Variable = ReadLineFromOldTextFile
    3. If Left$(Variable, Len)SearchString)) = SearchString Then Variable = ChangedVariable
    4. Write Variable to NewTextFile
    5. When done, close and delete original text file
    6. close new text file and rename it to original text file's name.
    ~seaweed

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