myspacee Posted April 9, 2008 Share Posted April 9, 2008 (edited) Hello, i need support. I've a big file : ___________________8<______________ .... random text .... random text from: me@gmail.com to: goofy@gmail.com subject: need help .... random text .... random text from: goofy@gmail.com to: goofy@gmail.com subject: no problem use autoit .... random text .... random text _________________________________ -> With readline function i can read line x line : $file = FileOpen("test.txt", 0) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop MsgBox(0, "Line read:", $line) Wend FileClose($file) -> I need help to skip line, join values, if a 'mark' is found (word "From: " ) ES: While 1 $line = FileReadLine($file) ;myline = readline() If $line = "From: " then ; if myline = From: $myinfo = $line ;store this line -=skip a line=- ;skip a line because next line If $line = "to: " then ;can be = to: $myinfo = $myinfo + $line ;if so join lines endif endif MsgBox(0, "myinfo are:", $myinfo) Wend A bit confused, but can anyone help me ? Than you ! Edited April 9, 2008 by myspacee Link to comment Share on other sites More sharing options...
someone Posted April 9, 2008 Share Posted April 9, 2008 This isn't doing it exactly the way you did above, but I think you will find it easier working with _FileReadToArray then FileReadLine for what you want to do. In this example the code will search test.txt (populated with the text you posted above) for each From and To line. The only possible negative is I have no idea which way, _FileReadToArray or FileReadLine will give you better performance. Its an educated guess to say _FileReadToArray, but still a guess. Let me know if this is what you were looking for. #include <file.au3> Dim $avArray If Not _FileReadToArray(@DesktopDir & "\test.txt",$avArray) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf _ArrayDisplay($avArray) For $i = 1 to $avArray[0] If StringInStr($avArray[$i], "From:") Then $line = $avArray[$i] Msgbox(0, "From:", $line) EndIf If StringInStr($avArray[$i], "to:") Then $myinfo = $avArray[$i] Msgbox(0, "to:", $myinfo) EndIf Next $myinfo &= @CRLF & $line MsgBox(0, "Combined", $myinfo) While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
myspacee Posted April 10, 2008 Author Share Posted April 10, 2008 solved in this manner: expandcollapse popup$file = FileOpen("c:\a\Posta in arrivo.dbx", 0) dim $store dim $my_master_counter dim $my_skip_counter $my_store = "" ;text box To collect info $my_master_counter = 0 ;counter for While $my_skip_counter = 0 ;conter for skip operations While 1 $my_master_counter = $my_master_counter + 1 ;every while add master counter + 1 $line = FileReadLine($file, $my_master_counter) ;read current line If @error = -1 Then ExitLoop ;id EOF exit if StringLeft($line, 13) = "Message-Id: <" Then ;find test of my interest $store = $line ;store actual text line $my_skip_counter = $my_master_counter ;my skip_counter = master_counter $my_skip_counter = $my_skip_counter + 1 ;to JUMP forward one line add 1 $line = FileReadLine($file, $my_skip_counter);read $store = $store & " | " & $line ;and store info $my_skip_counter = $my_master_counter ;RESET skip_counter (= master_counter) $my_skip_counter = $my_skip_counter - 1 ;to JUMP backward one line remove 1 $line = FileReadLine($file, $my_skip_counter);read $store = $store & " | " & $line ;and store info msgbox(0,"Find !", $store) EndIf Wend FileClose($file) brutal, but work. Can anyone do a little FUNC for this ? this tool, to open windows 'Outlook Express' db (.dbx) and collect a lot of info (works!) viva Autoit. m. 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