BinaryCopy

Copies bytes of data from one binary buffer to another.

Syntax:

BinaryCopy( handle targ, offset-targ, handle-src, offset-src, count)

Parameters:

(i) handle: targ handle of target buffer.

(i) offset-targ: zero-based offset into the target buffer specifying where the data to be copied should be placed.

(i) handle-src: handle of the source buffer.

(i) offset-src: zero-based offset into the source buffer specifying where the data to be copied starts.

(i) count: the number of bytes to copy.

Returns:

(i) byte count: number of bytes actually copied. The byte count may be lower than that specified in the command if the source block does not contain sufficient data.

 

Use this function to move blocks of data from one binary buffer to another one. Count bytes are transferred from the handle-src buffer starting at offset-src to the handle-targ buffer starting at offset-targ.

 

Example:


; This example edits the config.sys file
; and adds a new line at the top of the file.
;
fs1 = FileSize("C:\CONFIG.SYS")
binbuf1 = BinaryAlloc(fs1)
BinaryRead(binbuf1, "C:\CONFIG.SYS")
binbuf2=BinaryAlloc(fs1 + 200)
n = BinaryPokeStr(binbuf2, 0, "Rem Note new line at top")
a2=BinaryCopy(binbuf2, n, binbuf1, 0, fs1)
BinaryWrite(binbuf2, "C:\CONFIG.SYS")
binbuf2 = BinaryFree(binbuf2)
binbuf1 = BinaryFree(binbuf1)
Message("BinaryCopy", "Done.")
See Also:

Binary Operations, BinaryAlloc, BinaryFree, BinaryRead, BinaryReadEx, BinaryWrite, BinaryWriteEx