Try OpenEdge Now
skip to main content
Programming Interfaces
Input/Output Processes : Alternate I/O Sources : Sharing streams among procedures : Using stream object handles
 
Using stream object handles
Stream object handles allow you access named streams defined in routines (procedures, persistent procedures, user-defined functions, and methods of classes). The ABL Virtual Machine (AVM) implicitly creates a stream object when an application first tries to get the handle to a named stream, and deletes it when the routine that defines the stream terminates.
Note: You cannot use handles for the unnamed streams. By default, ABL provides two unnamed streams for input and output.
Like other ABL handle-based objects, you access stream attributes and methods using the object handle. Unlike other ABL handle-based objects, you use a DEFINE(and not a CREATE) statement in conjunction with streams.
All ABL statements that take a STREAM parameter can take STREAM-HANDLE parameter. For example:
DOWN [STREAM stream| STREAM-HANDLE handle][expression]
{[frame-phrase]}
The STREAM-HANDLE option takes an expression that evaluates to a stream handle. An application can use the STREAMname option or the STREAM-HANDLEhandle option, but cannot use both in the same statement.
The following example shows how you define a stream and access the handle to the stream:
DEFINE VARIABLE hStream AS HANDLE NO-UNDO.
DEFINE STREAM myStream.

hStream = STREAM mySTream:HANDLE.
For more information, see the DEFINE STREAM statement and the stream object handle section in OpenEdge Development: ABL Reference.