COS How to set Ens.StringContainer to String Value

487 Views Asked by At

I like to understand how you can set Ens.StreamConainer to a string value. I just see a class for setting the OriginalFilename but nothing for setting the body.

s pRequest = ##class(Ens.StreamContainer).%New()
s pRequest.OriginalFilename = "Test"
d pRequest.Stream.Read(hl7) //Error Out
d pRequest.StreamSet(hl7) //Getting empty string 
1

There are 1 best solutions below

0
On BEST ANSWER

If hl7 is a stream:

s pRequest = ##class(Ens.StreamContainer).%New(hl7)

It hl7 is a string:

s pStream = ##class(%Stream.GlobalCharacter).%New()
do pStream.Write(hl7)
s pRequest = ##class(Ens.StreamContainer).%New(pStream)

Some code advice:

d pRequest.Stream.Read(hl7) //Error Out

Read reads from stream, and Write writes to stream.

d pRequest.StreamSet(hl7) //Getting empty string

It is a setter method for Stream property. There's no need to call it directly, just set the property.