This class is responsible for streaming data to memory. A MemoryOutputStream object enables write operations to memory and is expandable. It encapsulates the MEMPTR data type and simplifies MEMPTR operations.
Progress.IO.MemoryOutputStream extends Progress.IO.OutputStream:
As with other output stream classes, the MemoryOutputStream class maintains its own internal write position and eliminates the need to keep track of MEMPTR write positions.
PUBLIC MemoryOutputStream ( ) PUBLIC MemoryOutputStream (INPUT size AS INT64) |
When size is not specified, the Data and Length properties are initialized to 0.
The following table illustrates values that result from constructors and Write( )/Clear( ) methods:
DEFINE VARIABLE testDate AS DATE INITIAL "4/10/56". DEFINE VARIABLE testDouble AS DECIMAL INITIAL 42.42. DEFINE VARIABLE testFloat AS DECIMAL INITIAL 42.42. DEFINE VARIABLE testLong AS INTEGER INITIAL 42. DEFINE VARIABLE testShort AS INTEGER INITIAL 42. DEFINE VARIABLE testString AS CHARACTER INITIAL "Progress". DEFINE VAR InMs AS Progress.io.MemoryInputStream. outMs = NEW Progress.io.MemoryOutputStream(). outMs:WriteLong(INTEGER( testDate )). outMs:WriteDouble(testDouble). outMs:WriteFloat( testFLOAT). outMs:WriteLong(testLONG). outMs:WriteShort(testSHORT). outMs:Write(testString). InMs = NEW Progress.io.MemoryInputStream(INPUT outMs:Data ). MESSAGE InMs:ReadLONG() SKIP InMs:ReadDOUBLE() SKIP InMs:ReadFLOAT() SKIP InMs:ReadLONG() SKIP InMs:ReadSHORT() SKIP InMs:ReadSTRING() VIEW-AS ALERT-BOX. |
DEFINE VAR InMs1 AS Progress.io.MemoryInputStream. DEFINE VAR InMs2 AS Progress.io.MemoryInputStream. DEFINE VAR outMs AS Progress.io.MemoryOutputStream. DEFINE VAR len AS INT64. DEFINE VAR ret AS INT64. DEFINE VAR ch AS CHAR. DEFINE VAR lc1 AS CHAR. outMs = NEW Progress.io.MemoryOutputStream(). outMs:Write("PROGRESS1",YES). outMs:Write("PROGRESSx2",YES). InMs1 = NEW Progress.io.MemoryInputStream(INPUT outMs). MESSAGE InMs1:ReadString() VIEW-AS ALERT-BOX. MESSAGE InMs1:ReadLongchar() VIEW-AS ALERT-BOX. |