Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Thus this UDF, similar to the existing BinaryStrCnt function that can count the number of occurances of binary data in a binary buffer
#DefineFunction BinaryStrCntBin(bb,startoffset,endoffset,lookfor) count=0 While @TRUE startoffset=BinaryIndexBin(bb,startoffset,lookfor,@FWDSCAN,@TRUE) If startoffset== -1 Then Break startoffset=startoffset+1 If startoffset > endoffset Then Break count=count+1 EndWhile Return(count) #EndFunction ;Test case fn="c:\stuff\a.wbt" ; for the test case this is *this* script fs=FileSize(fn) bb=BinaryAlloc(fs) BinaryRead(bb,fn) ;count number of occurances of "offset" using existing method. x=BinaryStrCnt(bb,0,fs-1,"offset") ;Setup buffer with search string (could be binary data) cc=BinaryAlloc(100) BinaryPokeStr(cc,0,"offset") ;Search for the data with the UDF y=BinaryStrCntBin(bb,0,fs-1,cc) BinaryFree(bb) BinaryFree(cc) Message("x y",StrCat(x,@CRLF,y))
Article ID: W16243
File Created: 2004:03:30:15:43:32
Last Updated: 2004:03:30:15:43:32