Question
· Oct 10

Simple Way To Compare Streams

Is there a simple way to compare Stream data between two objects?

We have used $ZCRC to create a checksum and that seems to be work.

We have also read each line of the streams and compared them and that seems to work too.

We just think there has to be a simpler way than looping through all the lines of the stream.

Any suggestions would be appreciated.

Product version: IRIS 2023.1
$ZV: IRIS for Windows (x86-64) 2023.1.2 (Build 450_0_22859) Mon Dec 4 2023 14:32:44 EST
Discussion (7)3
Log in or sign up to continue

very quick and dirty test, probably only works on small streams, also needs to actually read the whole stream for compare.

 

# test compare - streams are same
set stream1=##class(%Stream.TmpCharacter).%New()
set stream2=##class(%Stream.TmpCharacter).%New()
do stream1.WriteLine("ABC123")
do stream2.WriteLine("ABC123")
do stream1.Rewind()
do stream2.Rewind()
w (stream1.Read() = stream2.Read())

1

# test compare - stream are different
set stream1=##class(%Stream.TmpCharacter).%New()
set stream2=##class(%Stream.TmpCharacter).%New()
do stream1.WriteLine("ABC123")
do stream2.WriteLine("DEF456")
do stream1.Rewind()
do stream2.Rewind()
w (stream1.Read() = stream2.Read())

0