Error track in "OUTPUT TO" statement

Team,
Consider the below scenario; I have to write data to a file which doesn't exist. Henceforth in this case Progress tries to create a new file. But i haven't given the folder permission, so Progress will throw an error in this case.

I hope "OUTPUT TO" statement doesn't have NO-ERROR option to capture this error. Is there some other way to handle this error?

Thanks in advance..!
 

TomBascom

Curmudgeon
You could use FILE-INFO to check the directory before attempting the operation.

You can handle the error with:
Code:
do on error undo, retry:
  if retry then
    do:
      message "oops!".
      leave.
    end.
  output to "xxx".
  message "hello world".
  output close.
end.

(This will handle the error but it will not suppress it...)
 
Hi Tom,
It was very useful. I hope we can not suppress the error but we can surpass the error by adding a "HIDE MESSAGE NO-PAUSE". ;-) I tried out something in below fashion and it is working as expected. It would be of great help if you can validate the below modification and let me know your thoughts. Thanks in advance..!

do on error undo, retry:
if retry then
do:
HIDE MESSAGE NO-PAUSE.
message "oops!".
leave.
end.
output to "xxx".
message "hello world".
output close.
end.
 

Stefan

Well-Known Member
You can supress the error message with a structured error handling CATCH:

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

CATCH e AS progress.lang.proerror:
   MESSAGE 'cannot access folder' VIEW-AS ALERT-BOX.
END CATCH.
 
Ya true Stefan, nice idea.. but we will miss the services of OOPS in our application as of now. We are planning to work out with services of OOPs only after couple of months. I will make a note of this approach as well, would be helpful moving forward. Thanks Stefan.
 

tamhas

ProgressTalk.com Sponsor
The new error handling does not require you to do OO. It works perfectly well with traditional ABL programming.
 
Top