How to know whether a text file is opened - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to know whether a text file is opened

blackr12345blackr12345 Posts: 4Member
Hi there, I have a very urgent problem.

So I'm writing a program with text files.
The text file, "account", will need to be accessed and edited (rewrite, reset, append).

So if I have left the file opened before I enter the Edit Procedure of my program, there would be an error. (I know this but I need to prevent from this)

So if I don't enter the program, resetting and reading the file do not make any error. (of course)

Now I need to be noticed before I enter the procedure. I want to warn the user to stop/quit the "account" text file so that my program could successfully edit the file in the Edit Procedure.

I think I need a command that could "distinguish" or give me an error code (like IOresult) so I could fix this fatal error.

Any ideas would be appreciated. Thank you.
Sign In or Register to comment.