` File not open error when file is opened (Dan Presnell ) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Par2: File not open error when file is opened
1999-06-07 -- Dan Presnell
 
I'll explain why leaving a file open can cause a not open error. Basically, it's because ABC doesn't know when a file is closed by the CLOSE(FILE) procedure or by automatic closing on thread termination. ABC "remembers" itself whether a file was open or not. Suppose this sequence: ProcA executes. It's on thread 1. ABC opens the file and remembers it was opened on thread 1. ProcB executes, on thread 2. ABC checks, sees that the file has not been opened on thread 2, then opens it, and remembers that it's open on thread 2 now. ProcA terminates. The Clarion runtime library closes the file on the termination of this thread (thread 1). This is automatic behavior that is supplied by the runtime library. But ABC is not instructed to close the file with the close method. ABC has no idea that the file has been closed by the thread termination. So ABC still thinks (from its own memory) that the file is still open on thread 1. Now ProcA (or any other procedure) executes. Thread 1 is available, so it executes on thread one. ABC checks itself to see of the file is open on thread 1. It sees that it is. (This is wrong, of course, but that is what ABC "remembers" because ABC never closed the file on thread 1.) So it doesn't open the file, thinking the file is already opened on that thread. Then when you do something with the file, you get a file not opened error. If the procedure executing here is other than ProcA, say ProcC, then this is where the error appears, even though the real coding error is somewhere else entirely. That makes it difficult to track down a mismatched close method for ABC methods. Sometimes, even, there is no apparent mismatch in the code, but something causes a return from a procedure before the ABC close method is called.


Today is November 21, 2024, 3:45 am
This article has been viewed 35199 times.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: