Way to check if a STREAM is open?

Posted by Ken Ward on 20-Jun-2019 14:22

I have a procedure that will optionally take a message and redirect it to a log file. The issue is that the log file is not always available depending on the situation. I'd like to be able to test if the stream is open and then only write the message if it is, otherwise I get error 1387.

I've been through the documentation and have searched the KB, but haven't found anything.

Posted by George Potemkin on 20-Jun-2019 14:31

if seek(stream) ne ? then "STREAM is open".

All Replies

Posted by George Potemkin on 20-Jun-2019 14:31

if seek(stream) ne ? then "STREAM is open".

Posted by Rick Terrell on 20-Jun-2019 15:56

Yes, wouldn't it be nice if the "stream handle" were a real handle with properties and methods to test these kinds of things, instead of just something to pass around.  Things like (just suggestions):


IS-OPEN

DIRECTION (input/output)

SOURCE (if an input stream)

DESTINATION (output stream)

SEEK (or something similar to tell you how far you are in reading an input stream)

OUTPUT-SIZE (how big is the file we've written so far.  This would be nice to have on the SAX-WRITER as well)


There are others that would be useful, but you get the idea.



Posted by Peter Judge on 20-Jun-2019 16:26

There are a bunch of Progress.IO classes that have (some of) that functionality
 
 
 

Posted by Ken Ward on 20-Jun-2019 20:28

I didn't know you could use SEEK like that.

Posted by Ken Ward on 20-Jun-2019 20:30

I was honestly expecting something like this as well.

It turns out that I could use the CATCH exception handling to trap this error as well, but the SEEK solution is cleaner-looking.

This thread is closed