|
-
Feb 13th, 2004, 01:06 AM
#1
Thread Starter
Fanatic Member
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
-
Feb 13th, 2004, 07:43 AM
#2
Frenzied Member
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.
-
Feb 13th, 2004, 08:12 AM
#3
Frenzied Member
>>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:
Open myfile for output as #1
'... do something
close #1
instead, do this:
VB Code:
Dim nfile as integer
nfile = freefile
Open myfile for output as #nfile
' ... do something
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.
-
Feb 13th, 2004, 08:14 AM
#4
Frenzied Member
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. 
-
Feb 13th, 2004, 08:20 AM
#5
Frenzied Member
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.
-
Feb 13th, 2004, 09:08 AM
#6
Thread Starter
Fanatic Member
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
-
Feb 13th, 2004, 09:11 AM
#7
Frenzied Member
Migrate to a database instead of a text file. That's the easiest solution to your problem. (And the most efficient)
-
Feb 13th, 2004, 01:08 PM
#8
Thread Starter
Fanatic Member
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.
-
Feb 14th, 2004, 09:12 AM
#9
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|