Results 1 to 9 of 9

Thread: dual open (urgent)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    526

    Exclamation dual open (urgent)

    Hi Pals,

    I need your help please.

    I am using open statement in my one form that reads & writes to few files (ASCII/TXT type).

    In another form i want to open those files for only reading.

    But when i use open statement then if i read and at that time they are processing the i get error file already open.

    I have a form that appends data to a file. If i want another form to read the data that is being appended in that file then what do i do ??

    Is there a way i can use open statement to permit multiple access or do something.

    Can anyone let me know how can i do both activities without getting error or so.

    Thank you,
    Greatchap

  2. #2
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    Couldn't you just make one form wait till the other form's done write? Set a global var called something like, bWrote As Boolean

    Then have a timer on the read form to constantly check if it's done, or much easier just call a public function when it's done writing.
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  3. #3
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    >>I have a form that appends data to a file. If i want another form to read the data that is being appended in that file then what do i do ??

    1) If you just want to read what is being appended to the file onto another form, why would you read it out of the file???? You already have it in your app, obviously, so why not write it to the second form at the same time you do the append?

    2) If you're getting a "file already open" error, you're probably using the same file descriptor. You probably have this:
    VB Code:
    1. Open myfile for output as #1
    2. '... do something
    3. close #1
    instead, do this:
    VB Code:
    1. Dim nfile as integer
    2. nfile = freefile
    3. Open myfile for output as #nfile
    4. ' ... do something
    5. Close #nfile

    And if you're trying to open two files at the same time, create 2 nfile vars and use a freefile on both of them so that you're sure to get a free file number.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    I think he is getting the error because he is loading the same file from multiple places simultaneously, not because he has used the same number for n in the #n.
    Have I helped you? Please Rate my posts.

  5. #5
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    My bad. I thought you could open a file for input and output at the same time. Nevermind. My first point is still valid tho.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    526

    Post

    Hi pals,

    Actually i have a program that actually reads & appends data to stock market company file (txt). So while its doing that if some one wants to open a particular txt file to see its contents and then when i try to open it just to read then an error occurs.

    I want that user should be able to view data (read only) no matter if the file(s) being updated.

    how can i achieve this ??

    Thanks for help

  7. #7
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Migrate to a database instead of a text file. That's the easiest solution to your problem. (And the most efficient)
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    526
    Originally posted by ober5861
    Migrate to a database instead of a text file. That's the easiest solution to your problem. (And the most efficient)
    No thats not possible. There must be some solution.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    526

    got solution

    HI,

    I GOT SOULTION TO MY PROBLEM. I WAS USING FREE FILE THEN I MADE AN ERROR LATER IN CODE BY NOT USING THAT VAR.

    THANKS FOR HELP ANYWAYS.

    Bye

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