Ernesto is an Avid Commentator
2 published comments for 2022
User bio
404 bio not found
Member since Jun 3, 2016
Posts:
Ernesto has not published any posts yet.
Replies:

When using the old stream classes (%Library.GlobalXXXXStream) you should never set a stream property A to the oref from another stream B, as the Location value of stream B will be copied into stream A. You should use CopyFrom to avoid this Location change.

Taking @Lorenzo Scalese  sample method add2(), it should be rewriiten as:

ClassMethod add2() As %Status
{
   Set = ..%New()
   Set st = ##class(%GlobalBinaryStream).%New()
   Do st.Write("azeruiop")
   //Set o.st = st
   Do o.st.CopyFrom(st)
   Quit o.%Save()
}
 

If you use the new stream classes %Stream,GlobalXXXX, the original code from method add2() will keep the Location from stream property:

ClassMethod add2() As %Status
{
Set = ..%New()
Set st = ##class(%Stream.GlobalBinary).%New()
Do st.Write("azeruiop")
Set o.st = st
Quit o.%Save()
}

 

Great code Julius!

To fix the problem with leading spaces, you can use :

Set data = $zstrip(data,"<>"," ")

It's not a pretty solution but you can achieve it using a terminal script (iristerm/cterm). The script will call your routine and when it ends it will throw a popup alert informing that your routine did finish. It will not bring the terminal to the foregroung but you get the alert.

Save this to a file:

send: d ^myRoutine<cr>
wait for: USER>
execute: mshta vbscript:Execute("msgbox ""Routine myRoutine finished processing."",48:close")

In terminal, press ALT+S and select the your script file and when the routine ends you will see a popup.
 

Followers:
Ernesto has no followers yet.
Following:
Ernesto has not followed anybody yet.
Global Masters badges: