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 myDate AS DATE INITIAL "1/1/2020". DEFINE VARIABLE myInt64 AS INT64 INITIAL 42. DEFINE VARIABLE myDouble AS DECIMAL INITIAL 42.42. DEFINE VARIABLE myFloat AS DECIMAL INITIAL 42.42. DEFINE VARIABLE myLong AS INTEGER INITIAL -53. DEFINE VARIABLE myShort AS INTEGER INITIAL -53. DEFINE VARIABLE myULong AS INTEGER INITIAL 123456789. DEFINE VARIABLE myUShort AS INTEGER INITIAL 12345. DEFINE VARIABLE inMs AS Progress.IO.MemoryInputStream. DEFINE VARIABLE outMs AS Progress.IO.MemoryOutputStream. outMs = NEW Progress.IO.MemoryOutputStream(). outMs:WriteLong(INTEGER(myDate)). outMs:WriteInt64(myInt64). outMs:WriteDouble(myDouble). outMs:WriteFloat(myFloat). outMs:WriteLong(myLong). outMs:WriteShort(myShort). outMs:WriteUnsignedLong(myULong). outMs:WriteUnsignedShort(myUShort). inMs = NEW Progress.IO.MemoryInputStream(INPUT outMs:Data). MESSAGE "ReadLong:" inMs:ReadLong() SKIP "ReadInt64:" inMs:ReadINT64() SKIP "ReadDouble:" inMs:ReadDouble() SKIP "ReadFloat:" inMs:ReadFloat() SKIP "ReadLong:" inMs:ReadLong() SKIP "ReadShort:" inMs:ReadShort() SKIP "ReadUnsignedLong:" inMs:ReadUnsignedLong() SKIP "ReadUnsignedShort:" inMs:ReadUnsignedShort() SKIP VIEW-AS ALERT-BOX. |
DEFINE VARIABLE outMs AS Progress.IO.MemoryOutputStream. DEFINE VARIABLE InMs1 AS Progress.IO.MemoryInputStream. DEFINE VARIABLE InMs2 AS Progress.IO.MemoryInputStream. 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 STRING(InMs1:ReadLongchar()) VIEW-AS ALERT-BOX. |