Modifying %Stream contents
I have a %Stream that I want to insert some text into the middle of. I create a new stream called pNewContentStream from the original stream, then I do a MoveTo in pNewContentStream to get to the byte position I want to insert into but when I do my Write, my pNewContentStream gets obliterated with only the text that I wrote, the original content goes away and all I'm left with is my Write text.
Method AddContentTypeCode4(pContentStream As %Stream.GlobalCharacter, Output pNewContentStream As %Stream.GlobalCharacter) As %Status { Set tStatus = $$$OK try { Set tTemp = pContentStream.Read() $$$HSTRACE("AddContentTypeCode4[1]","tTemp",tTemp) Set pNewContentStream=##class(%GlobalCharacterStream).%New() $$$HSTRACE("New Stream") Set tStatus = pNewContentStream.CopyFrom(pContentStream) $$$HSTRACE("AddContentTypeCode4[2]","tStatus",tStatus) Do pNewContentStream.Rewind() $$$HSTRACE("AddContentTypeCode4[3]","pContentStream,pNewContentStream",pContentStream,pNewContentStream) Set tLocatorString = "<ns2:Description>" Set tInsertPoint = pContentStream.FindAt(1,tLocatorString,.tStr,0) Set tInsertPoint = tInsertPoint+$LENGTH(tLocatorString) $$$HSTRACE("AddContentTypeCode4[4]","tInsertPoint,pNewContentStream",tInsertPoint,pNewContentStream) Set tStatus = pNewContentStream.Rewind() Set tStatus = pNewContentStream.MoveTo(tInsertPoint) $$$HSTRACE("AddContentTypeCode4[5]","tStatus",tStatus) Set tStatus = pNewContentStream.Write(..ContentTypeCodeInsertable) $$$HSTRACE("AddContentTypeCode4[6]","tStatus,pContentStream,pNewContentStream",tStatus,pContentStream,pNewContentStream) Do pContentStream.MoveTo(tInsertPoint) Set tRemain = pContentStream.Read() Do pNewContentStream.Write(tRemain) $$$HSTRACE("AddContentTypeCode4[n]","pContentStream,pNewContentStream",pContentStream,pNewContentStream) /// Set pNewContentStream.ContentType = tContentTypeCode } catch ex { Set tStatus = ex.AsStatus() }
The trace labeled "AddContentTypeCode4[6]" shows tStatus = 1, pContentStream is intact and is as expected, pNewContentStream contains whatever was in ..ContentTypeCodeInsertable
What I was hoping to happen was at least having the beginning of pContentStream, then have the contents of ..ContentTypeCodeInsertable but instead I only get the contents of ..ContentTYpeCodeInsertable. Any suggestions? Thanks!
Marlin
So, now you have an old stream, "This is my text" but want to have a new stream as "This is my NEW text".
And now, check the resulty
Thanks! I will check that out.
@Marlin Mixon
It is just not possible the way you tried. Because: (from class docs)
This means it does a Rewind() and a Read(position)
• method Write(data As %RawString) as %Status
@Robert: Thanks. I'll study this to get a better idea where I went wrong!
@Julius: That works. Showing my revised code:
Or so:
GREAT!
%IO* is invisible in my local Class Reference
In Caché all classes is visible, and in IRIS, you need to enable their display.
Is there a special trick to making %IO visible? Selecting the "Percent Classes" checkbox doesn't do it.
Yes.
By default, a strictly defined list of packages/classes is displayed in IRIS for security purposes, but you can change this behavior locally.
Is the mechanism for doing this something you can share?
No. I couldn't find how to do this in the documentation (probably I searched badly), so I don't publish here undocumented features anymore.
But you can easily determine this from the source code.
The "easy" options indicated by the source code do some interesting things, but showing %IO* isn't among them. I'll keep looking
If you create a class, you can it declare as a hidden class, see
https://docs.intersystems.com/iris20211/csp/docbook/DocBook.UI.Page.cls?...
will be a hidden class.
For your own classes you can adjust this class keyword as you like but for the system classes - there is no chance, they lie somwhere on ISC servers (and, but this is my very own opinion, not very wise. First, I would like to read the documentation for the version I have installed (and not always the latest version) and second, I would like to read the doc everywhere! For example, I have a 10 hour flight, and want to work. And in case, a server only has a local LAN access, then you have no docu!).
I fully support it.
But I'm afraid now, apart from reading the documentation in PDF format, you can forget about local documentation ("DOCBOOK" database) with normal search and navigation. It's a pity..
Hi @Jeffrey Drumm . there are 2 options
#1)
.png)
From SMP > Explorer > Classes in %SYS set filter to %IO*.cls and Documentation
#2)
In Studio in NS %SYS load the class and show Class Documentation
[CTRL + SHIFT +F1]
and see the code. I have seen more thrilling constructs before.
Strange, the %IO class belongs to our production/development namespace.
We use 'Cache for Windows 2018.1.4'.
It's a "FEATURE" of recent IRIS to hide deprecated code
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue