WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Binary Operations

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

UDF-BinaryInsert

Keywords: 	  UDF-BinaryInsert

BinaryInsertStr inserts a string into a binary buffer
BinaryInsertStr inserts a STRING into a binary buffer
#DefineFunction BinaryInsertStr(binbuf,offset,DaString)
   binbufEOD=BinaryEodGet(binbuf)
   lenstring=StrLen(DaString)
   bbtemp=BinaryAlloc(binbufEOD)

   Remsize=binbufEOD-offset
   BinaryCopy(bbtemp,0,binbuf,offset,remsize)
   BinaryPokeStr(binbuf,offset,DaString)
   BinaryCopy(binbuf,offset+lenstring,bbtemp,0,remsize)
   BinaryFree(bbtemp)
   Return (lenstring)
#EndFunction

;BinaryInsert inserts a single numeric byte into a binary buffer
#DefineFunction BinaryInsertByte(binbuf,offset,byte)
   binbufEOD=BinaryEodGet(binbuf)
   lenbyte=1
   bbtemp=BinaryAlloc(binbufEOD)
   Remsize=binbufEOD-offset
   BinaryCopy(bbtemp,0,binbuf,offset,remsize)
   BinaryPoke(binbuf,offset,byte)
   BinaryCopy(binbuf,offset+lenbyte,bbtemp,0,remsize)
   BinaryFree(bbtemp)
   Return (1)
#EndFunction

;Examples

bb=BinaryAlloc(1000)
BinaryPokeStr(bb,0,"abcdefghijkl><mnipqrstuvwxyz")
ptr=BinaryIndexEx(bb,0,"<",@FWDSCAN,@TRUE)
BinaryInsertStr(bb,ptr,"inserted")
BinaryWrite(bb,"xxx.txt")
BinaryFree(bb)

bb=BinaryAlloc(1000)
BinaryPokeStr(bb,0,"abcdefghijkl><mnipqrstuvwxyz")
ptr=BinaryIndexEx(bb,0,"<",@FWDSCAN,@TRUE)
BinaryInsertByte(bb,ptr,65)
BinaryWrite(bb,"xxx1.txt")
BinaryFree(bb)

Article ID:   W15325
File Created: 2003:05:28:10:24:20
Last Updated: 2003:05:28:10:24:20