;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfIsStringInFile (strFilename, strSearch, intOffset, intDirection, blnMatchCase) ; The Binary Buffer version. If strSearch == "" Then Return @FALSE intFileSize = FileSize (strFilename) If intFileSize == 0 Then Return @FALSE If intOffset < 0 Then Return @FALSE If intOffset > intFileSize - 1 Then Return @FALSE hdlBB = BinaryAlloc (intFileSize) BinaryRead (hdlBB, strFilename) intOffset = BinaryIndexEx (hdlBB, intOffset, strSearch, intDirection, blnMatchCase) hdlBB = BinaryFree (hdlBB) Return intOffset > -1 ;.......................................................................................................................................... ; Detlev Dalitz.20031102. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ; Test. sMsgTitle = "Demo: udfIsStringInFile" strFilename = IntControl (1004, 0, 0, 0, 0) ; We use this file as test input. strSearch = "Test" intOffset = 0 If udfIsStringInFile (strFilename, strSearch, intOffset, @FWDSCAN, @FALSE) sMsgText = StrCat ("String found: ", strSearch) Else sMsgText = StrCat ("String not found: ", strSearch) EndIf Message (sMsgTitle, sMsgText) strSearch = "Direction" intOffset = 1600 If udfIsStringInFile (strFilename, strSearch, intOffset, @FWDSCAN, @FALSE) sMsgText = StrCat ("String found: ", strSearch) Else sMsgText = StrCat ("String not found: ", strSearch) EndIf Message (sMsgTitle, sMsgText) strSearch = "" intOffset = 0 If udfIsStringInFile (strFilename, strSearch, intOffset, @FWDSCAN, @TRUE) sMsgText = StrCat ("String found: ", strSearch) Else sMsgText = StrCat ("String not found: ", strSearch) EndIf Message (sMsgTitle, sMsgText) Exit ;------------------------------------------------------------------------------------------------------------------------------------------