Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FreeFile function

Status
Not open for further replies.

natashaXXX

Programmer
Sep 13, 2002
13
GB
I am using an MDI form as my main form. This has a menu which includes File Open. If every time I open a file, I use the freefile function, will the number generated by the freefile function be unique to this file. For example I want to put this number in an array, and every time I save the file I want to remove the number from the array. Will the freefilenumber be unique to that particular file?
 
No,

It will be unique all the time the file is open, but when you close the file, the number will be used the next file you open.

It is an incremental filehandle which just increases each time you open a file. when you close a file the filehandle is free and it can be used again to open anothe file.

Hope this helps,

Chris Dukes
 
If by "unique to this file" you mean, "unique to this form", then I belive the answer is no.

FreeFile will return the next available file handle. File handles may be re-used. Its possible that if you Open 1, Open 2, then close 1, then your next handle may again be 1. Because 1 had previously been close, 1 is available again. Trying to use FileHandles as some sort of unique key would, IMHO, not be a wise approach.

Perhaps with better understanding of your functional requirement, another appropach may come to light. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Actually, it is a bit worse than depicted above.


If you uyilize the freefile function multiple times w/o an intervening assignment of the returned value, freefile will (also) return the same value e.g.:

MyFil = FreeFil
? MyFil = 1
MyFil2 = Freefile
? MyFil, MyFil2
1[tab][tab]1

and so on.

As they say in the comics

'try it, you'll like it' (with NOT)

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top