Consultor Eletrônico



Kbase P77426: Error 1387 attempting to write to a stream defined in a persistent procedure
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   4/26/2004
Status: Unverified

SYMPTOM(s):

Error 1387 attempting to write to a stream defined in a persistent procedure

** Attempt to write to closed stream <stream>. (1387)

Stream is opened in the persistent procedure

Write operation takes place within an internal procedure in the persistent procedure

CAUSE:

Expected Behaviour. Any open streams should be closed when the procedure returns, even if it is persistent.

FIX:

This can be worked around in 3 ways:

1) The stream can be defined as a NEW GLOBAL SHARED:

DEFINE NEW GLOBAL SHARED STREAM sStream.


2) The stream should be opened and closed within the internal procedure:

PROCEDURE writeToStream:
OUTPUT STREAM sStream TO c:\temp\STREAM.txt.
PUT STREAM sStream "Write to file".
OUTPUT STREAM sStream CLOSE.
END PROCEDURE.


3) Define separate internal procedures within the persistent procedure to Open, Close and write to the stream:

PROCEDURE openStream:
OUTPUT STREAM sStream TO c:\temp\STREAM.txt.
END PROCEDURE.

PROCEDURE closeStream:
OUTPUT STREAM sStream CLOSE.
END PROCEDURE.

PROCEDURE writeToStream:
MESSAGE "Calling writeToStream" VIEW-AS ALERT-BOX.
PUT STREAM sStream "Write to file".
END PROCEDURE.