;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfIsStringInFile (strFilename, strSearch, intStart, intDirection, blnMatchCase) ; The FileGet version. If strSearch == "" Then Return @FALSE intFileSize = FileSize (strFilename) If intFileSize == 0 Then Return @FALSE If intStart < 1 Then Return @FALSE If intStart > intFileSize Then Return @FALSE strFile = FileGet (strFilename) If !!blnMatchCase intPos = StrIndex (strFile, strSearch, intStart, intDirection) Else intPos = StrIndexNC (strFile, strSearch, intStart, intDirection) EndIf Return !!intPos ;.......................................................................................................................................... ; Detlev Dalitz.20090424. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ; Test. sMsgTitle = "Demo: udfIsStringInFile" strFilename = IntControl (1004, 0, 0, 0, 0) ; We use this file as test input. strSearch = "Test" intStart = 1 If udfIsStringInFile (strFilename, strSearch, intStart, @FWDSCAN, @FALSE) sMsgText = StrCat ("String found: ", strSearch) Else sMsgText = StrCat ("String not found: ", strSearch) EndIf Message (sMsgTitle, sMsgText) strSearch = "Direction" intStart = 1600 If udfIsStringInFile (strFilename, strSearch, intStart, @FWDSCAN, @FALSE) sMsgText = StrCat ("String found: ", strSearch) Else sMsgText = StrCat ("String not found: ", strSearch) EndIf Message (sMsgTitle, sMsgText) strSearch = "" intStart = 0 If udfIsStringInFile (strFilename, strSearch, intStart, @FWDSCAN, @FALSE) sMsgText = StrCat ("String found: ", strSearch) Else sMsgText = StrCat ("String not found: ", strSearch) EndIf Message (sMsgTitle, sMsgText) Exit ;------------------------------------------------------------------------------------------------------------------------------------------