When should a stream be automatically closed?

When should a stream be automatically closed?

Post by alan » Sun, 11 Jul 2004 05:01:40


Or when does stream information get passed to subroutines?

Of the three types of routine calls, which should share stream info?
Should the Procedure statement have any affect of the streams?

1) A subroutine call within the same file should share the same
streams.
2) Should an external macro call affect a stream in the caller?
3) Should a RexxStart() call affect streams in running macros?
4) Maybe a called macro see the callers streams, but can't change
them...

Regina 3.0 will close all files after the first RexxStart() call
exits,
but Regina 3.3 keeps the file information around.
Both versions treat a Call filename the RexxStart(filename) the same.

I need to change Regina 3.3 to auto-close streams like Regina 3.0 did,
but I was wondering how global the stream information is in the Rexx
standard.

Thanks!
Alan

---File readme.rexx ----
Arg a
If (a = '') Then
Call readme.rexx 'first external macro CALL'
Call readit a 'first'
If (a = '') Then
Call readme.rexx 'second external macro CALL'
Call readit a 'second'

Exit 0

readit:
Arg b
fn = 'readme.rexx'
Say b 'lines='lines(fn) /* prints 1 or maybe 15 sometimes 0
*/

Do While (Lines(fn) <> 0)
c = Linein(fn)
End
Return 0
---------------------------------
Output from running "Rexx readme.rexx":
FIRST EXTERNAL MACRO CALL FIRST lines=19
FIRST EXTERNAL MACRO CALL SECOND lines=0
FIRST lines=0
SECOND EXTERNAL MACRO CALL FIRST lines=0
SECOND EXTERNAL MACRO CALL SECOND lines=0
SECOND lines=0
 
 
 

When should a stream be automatically closed?

Post by alan » Thu, 15 Jul 2004 04:35:58


After thinking about this, I am left with only two options.
Of the four types of routine calls:
Call labelName args - Same as x = labelName(args)
Call fileName args - Same as x = fileName(args)
Address System REXX fileName args
Address MySystem REXX fileName args - same for all calls to
RexxStart()

Both Call labelName and fileName inherit any open streams and leave
all streams open after exiting. Since System REXX starts a new
process all streams are closed on exit.
1) MySystem and System calls act the same. (close all files on exit)
2) MySystem inherits any open streams, and closes new streams on exit.

In Regina 3.3 MySystem calls will inherit any open streams and leave
all streams open after exiting.

I thing I'll go with whatever is easier to implement in Regina, unless
somebody has an opinion on how RexxStart() should be working. Or, with
luck somebody else (like Florian) will change it for me!

Best Regards!
Alan