TokeySmurf Posted June 23, 2007 Share Posted June 23, 2007 (edited) My code is probably all jacked up but what I'm trying to do is just get this code to match some text in the file and display the line it matches. Say on line 3 it has a keyword what it'd display that line. The func I am having problems with is the talk function.. Also I'm having problems geting it to make sure that the text file actually exsist so I just have it ; out right now. I tried doing if $fileName = -1 then msgbox(0,"error", "Does not exsist") endif but it doesn't work.. dunno.. Thanks again expandcollapse popup#include <GUIConstants.au3> #include <file.au3> GUICreate ("Brain", 300, 400) $learnButton = GUICtrlCreateButton ("Learn Knowledge", 100, 100) Global $learnInput = GUICtrlCreateInput ("Help me Learn", 5, 100) $talkButton = GUICtrlCreateButton ("Talk", 100, 300) Global $talkInput = guictrlcreateinput ("What are u looking for?",5,300) Guisetstate (@SW_SHOW) Global $fileName = "learn.txt" Global $file = fileopen (@scriptdir & "learn.txt",01) Global $user = "c-note" while 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit case $msg = $learnButton learn() Case $msg = $talkButton talk() EndSelect WEnd func learn() $learn = guictrlread ($learnInput) _filewritelog ($fileName, $user & ": start entry" & @CRLF) FileWriteLine ($fileName, $learn & @CRLF) FileWriteLine ($fileName, $user & ": end entry" & @CRLF ) EndFunc func talk() $data = fileread($fileName) GUICtrlRead ($talkInput) Select case $talkInput = $data filereadline ($text, $data) msgBox (0, "hey", $data) ;case $data = 0 ;msgbox(0,"teach me", "Please teach me") EndSelect EndFunc Thanks in advanced for all help Edited June 23, 2007 by TokeySmurf Link to comment Share on other sites More sharing options...
ResNullius Posted June 23, 2007 Share Posted June 23, 2007 ...Say on line 3 it has a keyword what it'd display that line. The func I am having problems with is the talk function.. Also I'm having problems geting it to make sure that the text file actually exsist so I just have it ; out right now. I tried doing if $fileName = -1 then msgbox(0,"error", "Does not exsist") endif but it doesn't work.. dunno.. Thanks againFor finding lines with keywords, you might want to check out StringInStr() in the helpfile. Likewise, if you're having problems with the -1 return of FileOpen (though I can't see why), check out FileExists() too. Link to comment Share on other sites More sharing options...
DW1 Posted June 23, 2007 Share Posted June 23, 2007 is this what you wanted? I am not quite sure what you are going for here, did you really want the Select? func talk() $data = fileread($fileName) If GuiCtrlReY ÌÍÝ[Ò[] HH ÌÍÙ]H[[XY[H ÌÍÝ^b33c¶FF¢×6t&÷ÂgV÷C¶WgV÷C²Âb33c¶FF¢VæD` ¢%ÀÌØíÑôÅÕ½ÐìÅÕ½ÐìQ¡¸(íµÍ½à À°ÅÕ½ÐíÉɽÈÅÕ½Ðì°ÅÕ½ÐNo text on line") EndIf EndFunc talk AutoIt3 Online Help Link to comment Share on other sites More sharing options...
TokeySmurf Posted June 23, 2007 Author Share Posted June 23, 2007 I couldn't get the second posters to work.. I used direct copy and paste to test functionality $data = fileread($fileName) If GuiCtrlRead($talkInput) = $data Then filereadline ("learn.txt", $data) msgBox (0, "hey", $data) EndIf If $data = "" Then ;msgbox(0,"Error", "No text on line") EndIf EndFunc I'm looking up the first posters right now.. as far as select goes it doesn't matter to me if it's if statements or case statements I can alter that later if needed.. thanks again Link to comment Share on other sites More sharing options...
randallc Posted June 24, 2007 Share Posted June 24, 2007 Hi, dir need s"\" too;Global $file = fileopen (@scriptdir & "learn.txt",01)Global $file = fileopen (@scriptdir & "\learn.txt",01)Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW 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