Streams Concept

anandknr

Member
Hi all,

Can somebody help me to figure out the actual concept/purpose of stream. The only thing that I have done with stream is to read/write files. I know there is something more than this about stream can do. Please share.
 

GregTomkins

Active Member
In other languages streams can mean many things, but in Progress ... AFAIK, it is 99% about reading and writing files. The 1% is that a stream could represent a pipe to and from a Unix process, which Unix considers to be a special case of file.
 
I used to write a summary and detail report at the same time, to save time. Another time created three reports at once: credit balance, debit balance and zero balance. I simply used if then else to determine which stream to write each to after looking the account balance.
Another time it might be useful for a data/xml file to be one output and another to be human readable.
 

GregTomkins

Active Member
In our shop, we use streams 99% of the time for any file access, even if only one report/file is being written. When I see stuff like 'OUTPUT TO foo', I kind of cringe a bit. In my mind, 'OUTPUT' and 'INPUT' should always be followed by the 'STREAM' keyword... but I can't rationalize why, it just seems right.
 

Cringer

ProgressTalk.com Moderator
Staff member
One thing about using streams is seen in the code below...

Code:
OUTPUT TO "c:\temp\test.txt".
MESSAGE "Where does this go?".
OUTPUT CLOSE. 



DEFINE STREAM s1.
OUTPUT STREAM s1 TO "c:\temp\test2.txt".
MESSAGE "Where does this go?".
OUTPUT STREAM s1 CLOSE.

In the example without a stream, the message goes to the file, whereas when you use a stream the message goes to screen. So if you use a stream, any screen messages will still appear on the screen. Which is quite a bonus IMO ;)
 

GregTomkins

Active Member
... and generated MESSAGEs such as 'FIND FIRST failed' work the same way. Which I guess is the argument in favour of STREAMs, that I was looking for ;)
 
Hello Everyone, I want to add few points into this:

1. Progress have its default stream which is connected to screen output. If we use OUTPUT TO statement then we redirect that default stream to somewhere else.
2. If we use DEFINE STREAM statement then we are creating the new stream and connecting that stream to its destination via OUTPUT STREAM l-strm TO VALUE(), apparently different stream from progress default stream.

Cringer's example describe the same.

Thanks!!!
 
Top