Jump to content

Generate a list of File Handles for files opened using FileOpen


Recommended Posts

I have a stand alone Close Program function that I call when I want to close the program so I don't have to keep adding it to each program.  I call it from any other program that I write where I could be doing anything.  The function does some simple error checking and provides a reason why the program is closing or asks the user are you sure you want to close the program.

In some instances, I may have one or more files open that I were opened using the FileOpen function when this function is called.  I know it is best practice to close any open files with the FileClose function prior to exiting the program.  What is the best way to pass any open file handles I might have created to that function so I can properly close them?  Is there a way to list any open file handles that the AutoIt program has created?

I thought about writing a simple file handler routine that stores all files and handles in a global variable so that it can be accessed at any time from any subroutine, but thought there might be a better way.

Any thoughts would be appreciated.

Edited by Husker_Jason
Link to comment
Share on other sites

Yea, I was looking for an easy way to keep track of them.  In the end I ended up just writing a function that goes between the FileOpen and FileClose commands that writes each new file I open to an array with the handle and file path and then removes those values from the storage array when I close them.  If there are any files still open when I close the program, it goes through and cleans them up.

Probably overkill as I know AutoIt automatically closes open files when it closes, but I like to keep things neat.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...