Click to See Complete Forum and Search --> : FreeFile
GerryQuinn
Nov 29th, 1999, 03:46 PM
My application is used by a number of users, all accessing(writing) to the same file.
Currently like so:
Open Filename For Append Access Write Lock Write As #1
If a user is writing to the file & another user tries to access the file, permission is denied. Error handler displays a message. Try later!!!
Should I hard-code file number, #1 or use Freefile to obtain next available number. Only one user can open & write to the file at once...
What are the benefits of using freefile, espcially with multiple users?
Gerry.
chrisjk
Nov 29th, 1999, 03:50 PM
You should use freefile in preference to a number every time in my opinion. Benefit being it is guaranteed to work (at least, it won't bust due to invalid file number).
There is no real point not using FreeFile (apart from 2 extra lines of code...damn! :))
Hope that clears it up
Regards,
------------------
- Chris
chris.kilhams@btinternet.com
If it ain't broke - don't fix it :)
[This message has been edited by chrisjk (edited 11-30-1999).]
also, using #1 may cause untold damage to "that comma-delimited file that i left open in notepad, which my customer desperately needs for tomorrow morning". Bitter, bitter experience!
examples of mad people who probably dont use FREEFILE:...
Evel Kneivel, Charly Manson, that feller out of hellraiser. (names changed to stop nasty libel proceedings)!
------------------
Wossname,
Email me: wossnamex@talk21.com :)
Frans C
Nov 30th, 1999, 11:57 AM
Using Freefile has nothing to do with multiple users. If you open multiple files from your application, it can be hard to make sure you haven't used the filenumber for another file already. Using Freefile makes sure you get a filenumber that isn't used already by your application. Also using #1 (or #9 or whatever) isn't as clear as using:
hLogFile = FreeFile
Open Filename For Append Access Write Lock Write As #hLogFile
Now the variable gives a clue about the purpose of the file, so if you open the file in line 100 of your code and you write to it in line 1050, it will be more easy to understand if you have to modify the app in a year or so.
So in my opinion, using FreeFile is recommended.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.