forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

File Handling Errors

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Clay



Joined: 20 Mar 2014
Posts: 23

PostPosted: Fri Mar 13, 2015 6:26 pm    Post subject: File Handling Errors Reply with quote

We've built an application which relies heavily on ClearWin functions such as Rename@ and Erase@. We call DosErr@ after these functions are used to handle any problems encountered. Increasingly over recent years we've had more and more of our customers getting one of these error pop-ups:
- "Cannot create a file when that file already exists"
- "The system cannot find the file specified"
- "Process cannot access the file because it is being used by another process"

Are these error messages being seen in other people's programs?

What are the common causes for these errors, i.e. what's causing the function to fail?

We suspect that when computer resources are being heavily used that (for example) an Erase@ command may take a long time to finish so that when a Rename@ command is used on the next line, the file we're trying to erase hasn't actually been erased yet. Does this seem like something that could happen, and if so, what can we do to prevent it?

We really like using ClearWin, but these errors are becoming a serious problem for our customers. The people reporting this problem seem to be using older computers with Windows XP and 4 GBRAM, but requiring all of our users to get a hardware upgrade would not be a popular solution!! Any advice or thoughts would be most appreciated!

Clay Jones
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Thu Jun 25, 2015 1:07 am    Post subject: Reply with quote

I have seen instances where it would appear that the file, having been deleted, is not actually deleted. It does appear that the newer, faster processors are out stripping the ability of the application to act as truly single threaded. I also see this kind of behavior when presenting windows/dialogs (ClearWin+).

I have also seen the effects of closing a file, then immediately re-opening it and having the reopen fail because the file is still being used by the OS (or whomever) and not yet relinquished.

While I can't swear to it, that's what it looks like.

I no longer use "NEW" for a file, but use 'REPLACE'. This has solved many problems with files not quite getting deleted (or closed).

One way to ensure that the file is truly deleted is use FEXISTS@ to see if the file is still there before you continue. Loop (for a while) until it is no longer there, then continue. I do something similar when I get an error that a file is in use, I loop for a pre-set number of times waiting for the file to become un-used, it then opens just fine. And, it happens all the time.
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Thu Jun 25, 2015 7:04 am    Post subject: Reply with quote

In this context it might be helpful to call sleep1@ for a small number of milliseconds within the "while loop" mentioned above.
Back to top
View user's profile Send private message AIM Address
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Thu Jun 25, 2015 8:27 am    Post subject: Reply with quote

There are several possibilities to delete a file. Immediately after closing the file can be done with close(10,status='delete') or closefd@ for files opened with openr@ or openw@. Further, instead of erase@ you can use DeleteFile from Windows (I prefer this). I'm not sure whether the time for deletion is the same in all cases, so you may try different ways.

Wilfried
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Thu Jun 25, 2015 8:24 pm    Post subject: Reply with quote

Just to be pedantic, RENAME@ and ERASE@ are DOS functions, present in FTN77 and carried over into FTN95 with nothing to do with Clearwin+ You don't find equivalent convenient routines in many other Fortran compilers, and even if you did, they would display the same behaviour in accessing such fundamental OS functions..

It looks like one of the jobs you do is to delete a file with a specific name, and then immediately afterwards open a different file with that particular name. You clearly don't want any of the original contents and you clearly want to write to it, because a file just opened will be empty.

So why don't you simply REWIND it?

As for RENAME@, you just rename a file then immediately afterwards, open another file with the original name. Why? Is there something of specific significance about the original name?

Surely, the correct procedure is to get a unique file name using TEMP_FILE@ when opening it, and RENAME@ that when you have finished with it. After all, Fortran only knows about the logical unit number after the OPEN statement has been executed, and the LUN is immediately available for a different file after the original one has had a CLOSE executed - regardless of how asynchronous windows might be dealing with delete and rename requests.

Eddie
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Fri Jun 26, 2015 12:18 pm    Post subject: Reply with quote

... and, while I'm at it, if the file you want to RENAME@ has just been filled by your application, and the renaming is a way of saving its contents, why don't you open it for writing with its intended final name?

Eddie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group