Results 1 to 3 of 3

Thread: Add text to specific line in text file???

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    13

    Add text to specific line in text file???

    I am working with a text file and adding lines to it using the for append as. I have five different controls that add a file name to the text file by clicking them. If I click on the first control it adds lets say text1 which is fine. Then if I click on the third control it adds text3. Which would look like this:

    text1
    text3

    The problem is that if click on the second control it adds text2 and the out come looks like this:

    text1
    text3
    text2

    How can i get the out come to look like this:

    text1
    text2
    text3

    The reason for this is the user right clicks on a control(image box) and can add a picture/thumbnail to the control. Then the file name of that picture gets put into the text file so when the user opens the program again it reads the text file and the picture is still there rather than being blank.

    I am trying to keep the order of the file names so they match the control the user assigned them to by simply reading each line of the text file.

  2. #2
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: Add text to specific line in text file???

    You'd be better off using an *.ini file. You could then use functions designed for use with *.ini files to read and write the information you wish to save. Search for that, I'm sure you'll find somthing.

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: Add text to specific line in text file???

    just add something after text3 telling it where to put the picture. That way it won't matter what order it is in in the file.

    example text file:
    text1, 3
    text2, 2
    text3, 1
    the benefit of this is when you read it in again, you could do this:
    open myfile for input as #1
    input #1, t$
    input #1, num

    and it will put the number in the num and the text part in t$
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

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