Wb-FreeKill Posted January 4, 2005 Share Posted January 4, 2005 I want to make a search "engine" for a html/txt file. Is it possible to search for a specific word in the file? Link to comment Share on other sites More sharing options...
ezzetabi Posted January 4, 2005 Share Posted January 4, 2005 May help $sFileName = '';Filename here $sWord = '';Se the word here $sText = FileRead($sFilename,FileGetSize($sfilename)) MsgBox(0,'',StringInStr($sText,$sWord)) Link to comment Share on other sites More sharing options...
Wb-FreeKill Posted January 5, 2005 Author Share Posted January 5, 2005 #Include <GUIConstants.au3> $sFileName = 'dansk-engelsk.html' $sWord = 'aftenandagt' $sText = FileRead($sFilename,FileGetSize($sfilename)) MsgBox(0,'',StringInStr($sText,$sWord)) it gives me the error o in the msgbox, is it because it cant find the file, or the word in the .html file? for eksample, i want it so search for a word in the .html document, and then show it on the msgbox, if it finds it! Link to comment Share on other sites More sharing options...
grakker Posted January 5, 2005 Share Posted January 5, 2005 Maybe a caps problem? #Include <GUIConstants.au3> $sFileName = 'dansk-engelsk.html' $sWord = 'aftenandagt' $sText = FileRead($sFilename,FileGetSize($sFileName)) <------------ MsgBox(0,'',StringInStr($sText,$sWord)) Link to comment Share on other sites More sharing options...
Wb-FreeKill Posted January 5, 2005 Author Share Posted January 5, 2005 what you mean? Link to comment Share on other sites More sharing options...
ezzetabi Posted January 5, 2005 Share Posted January 5, 2005 I just tested: $sFileName = 'c:\boot.ini';Filename here $sWord = 'part';Se the word here $sText = FileRead($sFilename,FileGetSize($sfilename)) MsgBox(0,'',StringInStr($sText,$sWord)) And it worked. Can you show a little more? Link to comment Share on other sites More sharing options...
Wb-FreeKill Posted January 5, 2005 Author Share Posted January 5, 2005 There is not more When i run your script, i get "59" why that? Link to comment Share on other sites More sharing options...
SlimShady Posted January 5, 2005 Share Posted January 5, 2005 There is not more When i run your script, i get "59" why that?<{POST_SNAPBACK}>I adjusted the code a little.$sFileName = 'c:\boot.ini';Filename here $sWord = 'part';Se the word here $sText = FileRead($sFilename,FileGetSize($sfilename)) If StringInStr($sText,$sWord) Then MsgBox(0,'', "Word is found in file!") Link to comment Share on other sites More sharing options...
ezzetabi Posted January 5, 2005 Share Posted January 5, 2005 RTM http://www.autoitscript.com/autoit3/docs/f...StringInStr.htm59 was the position of the 'part' string inside the c:\boot.ini file. Link to comment Share on other sites More sharing options...
Wb-FreeKill Posted January 5, 2005 Author Share Posted January 5, 2005 O, okay.. i tried to make a GUI aout of it, but it doesn't seem to work expandcollapse popup#include <GUIConstants.au3> global $sText GUICreate("Dictionary search", 300, 225) GUISetState(@SW_SHOW) $search = GUIctrlcreateinput("input search word",10,30, 150, 25) $button = GUICtrlCreateButton("Start Search", 10, 60, 70, 20) while 1 $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE then exitloop endif if $msg = $button then $sFileName = 'c:\fil.htm' $sWord = '(GUIread)$search' $sText = FileRead($sFilename,FileGetSize($sfilename)) If StringInStr($sText,$sWord) Then MsgBox(0,'', "Word is found in file!") endif If $sText = -1 Then MsgBox(0, "Error", "Unable to open file.") endif wend Can i get it to write the line were it found the word? thx for your help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now