Error Getting error 98 with Errno 13 when using an OUTPUT TO statement

Hi,

I've got this error:
Error 98 errno 13 when I using output to. I know why, it's because the file is open by someone and he propably lock it.

What I want it's be able to output to an other file in case the file is already open. Can some one help me?

Thank
 

TomBascom

Curmudgeon
What strategy do you want to employ to decide on when to do this? Offhand I can think of several:

1) Reactive -- Wait for an error to occur. Attempt to handle it and react. I've not tried but I suspect that the error you are getting is not trappable. Even if it is, it would mean adding a lot of code that would likely be messy and fragile.

2) Modestly proactive but really still reactive -- Test for the existence of the file. If it exists choose a different name. There is still a (small) window for collisions if the timing is just right. Naming mechanism is awkward.

3) Proactive -- choose unique names right up front. Simple and effective. No special error handling needed and much less awkward.
 

Osborne

Active Member
If as per Tom's post you want to go with (1) it is possible but as Tom points out it is a bit messy. From kbase P58614:
Since the syntax of the Progress 4GL OUTPUT TO statement does not allow the NO-ERROR option, a possible solution here is to redirect the generated errors to an error message log file for subsequent processing:
Code:
DEFINE VARIABLE cVariable AS CHARACTER NO-UNDO.

DEFINE STREAM ErrorStream.
DEFINE STREAM OutputStream.
 
OUTPUT STREAM ErrorStream TO "ErrorMessage.log" KEEP-MESSAGES.
 
MainBlock:
DO ON ERROR UNDO, RETRY:
   IF RETRY THEN DO:
      OUTPUT STREAM OutputStream CLOSE.
      OUTPUT STREAM ErrorStream CLOSE.
      LEAVE MainBlock.
   END.
   OUTPUT STREAM OutputStream TO myfile.txt.
END.
 
INPUT FROM VALUE("ErrorMessage.log") NO-ECHO.

IMPORT UNFORMATTED cVariable.
/* Replace following message statement with code */
/* for corrective action based on error message */
MESSAGE cVariable VIEW-AS ALERT-BOX INFO BUTTONS OK.

INPUT CLOSE.
 
Sorry guys I don't recive email from the forum to notify me new post... What you mean Stefan by "You can CATCH errors from OUTPUT TO". How?
 

Stefan

Well-Known Member
See earlier post in this forum.

Code:
OUTPUT TO c:/does/not/exist.txt. 

CATCH e AS progress.lang.proerror:
   MESSAGE 'cannot access folder' VIEW-AS ALERT-BOX.
END CATCH.
 
Top