BCOPY statement

Purpose: BCOPY does a binary copy from one object to another object of equal size. BCOPY will copy objects with embedded NULLs.


 Syntax:

 BCOPY binobject1 TO binobject2

 Parameters:

  • binobject1 binary object to be copied to binobject2.
  • binobject2 binary object to be copied from binobject1.

Example:


 DIM InBin$
 DIM LenInBin%
 
 InBin$=APPEXEPATH$ & "bcx.jpg"
 OPEN InBin$ FOR BINARY AS fp1
 LenInBin% = LOF(InBin$)
 DIM work$ * LenInBin%
 PRINT "File length is: "; LenInBin%
 
 GET$ fp1, work$, LenInBin%
 CLOSE fp1
 
 DIM newbin$ * LenInBin% 'new string same length as binary data in work$
 
 BCOPY work$ TO newbin$
 
 DIM OutBin$
 OutBin$=APPEXEPATH$ & "bcx2.jpg"
 OPEN OutBin$ FOR BINARY NEW AS fp1
 PUT$ fp1, newbin$, LenInBin%
 CLOSE fp1
 
 PRINT "File length is: "; LOF(OutBin$)
 KEYPRESS
 END

Remarks: Note well that the size of binobject1 and binobject2 should be the same! Also, when specifying a pointer it should be prefixed with a '*' dereferencing operator. For example,


 BCOPY *pv1 TO v2