Resolved Strange problem related to streams and break by totals.

JoseKreif

Member
Why is it that using a total will cause Progress to process code, even though it doesn't meet the condition?

Code:
def var yesno as log no-undo.
def stream s_file.

def temp-table t-table
field name as char
field age  as int.

create t-table.
assign
  name = "Bob"
  age = 44.

if yesno then
  output stream s_file to terminal.


for each t-table break by name:

  if yesno then
    display stream s_file
    age(total by name)
    with frame a.
end.

This throws the error ** Attempt to write to closed stream s_file. (1387)

if I replace age(total by name) with just age. Things work okay.

This is just a simplistic isolated example of a problem I am having. Don't think too much into why someone would want to total age. :/
 

Cringer

ProgressTalk.com Moderator
Staff member
Sounds like a call with tech support might be needed on this. Looks like a bug.
 

tamhas

ProgressTalk.com Sponsor
In your code, you never set yesno, so it will be false and so you will not have opened the stream.
 

JoseKreif

Member
In your code, you never set yesno, so it will be false and so you will not have opened the stream.

That's the point though. The code is executing when it shouldn't be. I didn't explicitly set yesno to false because it gets set to false by default, and since this is a small isolated example of the problem, I opted to save space by not being redundant.
 

tamhas

ProgressTalk.com Sponsor
Point being, based on the code you supplied, the error message is reasonable.
 

Cringer

ProgressTalk.com Moderator
Staff member
What happens when you put a DO: END. block around the display statement?
 

JoseKreif

Member
What happens when you put a DO: END. block around the display statement?

No difference. Thanks for suggestion though. Seems to be the way the language handles the total function. Nothing directly related to the stream. I was hoping to get an answer as to why, but unless the Progress team responds, it will remain a mystery.
 

TomBascom

Curmudgeon
IMHO the aggregate functions (such as TOTAL) are the work of the devil and should never be used.

But... it seems pretty obviously a bug. No code that writes to the stream ever executes. You can replace "yesno" with "false" and you still get the error.
 
Top