Results 1 to 7 of 7

Thread: Reading and Writing to/from files in the same operation [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Question Reading and Writing to/from files in the same operation [RESOLVED]

    Using the Open statement I can open text files for reading from, or writing to but not at the same time. Does anyone know how?

    I want to scan the lines of an existing text file and when I find certain things, I want to insert new lines in the appropriate places.
    Last edited by simonm; Apr 7th, 2003 at 08:51 AM.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    You can open it for Binary, and use Put and Get.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796
    "Put" and "Get"?

    VB doesn't recognise them and I can't find any reference to them in my MSDN library.

    We are talking VB here, aren't we?
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  4. #4
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    This is my VB6 code using PUT
    VB Code:
    1. DatNr = FreeFile
    2. DateiName = ReplayDateiPfad + "\Repl" + ReplayDatei + ".rp2"
    3. Open DateiName For Binary As DatNr
    4. Put DatNr, 1, Playtime
    5. l = Seek(DatNr)
    6. Put DatNr, i + 1, ChangeTime
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    They are statements.

    VB Code:
    1. Dim s As String
    2.  
    3.     s = Space$(5)
    4.  
    5. Open "c:\test.txt" For Input As #1
    6.     Get #1,,s 'Should get 5 bytes of text
    7.     Put #1,,"Test" 'Should write "Test" where the marker is positioned
    8. Close #1

    Its been a while since I've used them, I think that is right.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  6. #6

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796
    Yeah thanks.

    I see what you mean now.

    It's just a nightmare finding what you want in the MSDN library sometimes...
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  7. #7
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Originally posted by simonm
    It's just a nightmare finding what you want in the MSDN library sometimes...
    It works perfectly fine...as long as you know exactly what you want and where to find it.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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