How to shrink the content of a Binary Buffer?
;==========================================================================================================================================
;
; How to remove bytes from a binary buffer and shrink the buffer content accordingly?
;
;==========================================================================================================================================
;
; Overwrite the unwanted zone with binary zero values, and finally remove all binary zeroes.
;
;
; How to write zero bytes?
;
;    BinaryXor (hdlBB, intOffset, hdlBB, intOffset, intCount)
;
;    This fills in binary zeroes, starting at intOffset with a length of intCount bytes.
;
;
; How to remove zero bytes?
;
;    intBytesRemoved = BinaryReplace (hdlBB, "", "", @TRUE)
;
;..........................................................................................................................................
; (c)Detlev Dalitz.20030728.20100209.
;..........................................................................................................................................


; Example: How to shrink the content of a binary buffer?

strIn = "abcdefghijklmnopqrstuvwxyz"

intBBSize = StrLen (strIn)
hdlBB = BinaryAlloc (intBBSize)

intBytesPoked = BinaryPokeStr (hdlBB, 0, strIn) ; 26.
intEodIn = BinaryEodGet (hdlBB) ; 26.

BinaryXor (hdlBB, 6, hdlBB, 6, 14) ; Create 14 binary zeroes starting at offset 6.

intBytesRemoved = BinaryReplace (hdlBB, "", "", @TRUE) ; Remove zero bytes.
intEodOut = BinaryEodGet (hdlBB) ; 12.

strOut = BinaryPeekStr (hdlBB, 0, intEodOut)
hdlBB = BinaryFree (hdlBB)

strMsgTitle = "Example: How to shrink the content of a binary buffer?"
strMsgText = "In:" : @LF : strIn : "  (" : intEodIn : ")" : @LF : @LF : "Out:" : @LF : strOut : "  (" : intEodOut : ")"
Pause (strMsgTitle, strMsgText)

Exit
;==========================================================================================================================================