iceberg Posted June 5, 2008 Share Posted June 5, 2008 hi guys, appreciate if someone could shed some light on my doubts here....how can i achieve this? read the 3rd, 5th and 7th words of a text line by line and write it in another tetx file? thanks. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
Zedna Posted June 5, 2008 Share Posted June 5, 2008 Look at StringSplit() and use space as separator. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 5, 2008 Moderators Share Posted June 5, 2008 hi guys,appreciate if someone could shed some light on my doubts here....how can i achieve this?read the 3rd, 5th and 7th words of a text line by line and write it in another tetx file?thanks.Your search feature disabled?http://www.autoitscript.com/forum/index.ph...ghlite=%2Bwords Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
iceberg Posted June 5, 2008 Author Share Posted June 5, 2008 thanks Zedna.... i was looking at that function....took a while for me to figure out how it works. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
iceberg Posted June 5, 2008 Author Share Posted June 5, 2008 using the following codes i can't seem to read out the 3rd word in each line of the attached text file (log file) i believe my codes are right but it is just that it doesn't work for this text file particularly. what can i do? i need to read the 3rd (after , 7th and the word after "Invalid Comm Type". thanks. $Found = "No" $TxtFile = StringMid(@YEAR & @MON & @MDAY, 3) & ".txt" $OpenedTxtFile = FileOpen($TxtFile, 0) If $OpenedTxtFile = -1 Then MsgBox(48, "Error!", "File could not be opened. " & @CRLF _ & "1. Enter a valid path" & @CRLF _ & "2. Check if the file exists" & @CRLF _ & "3. Make sure you have access to the file" & @CRLF _ & "4. Check if the file is not opened by another program/script") Exit EndIf While 1 $Line = FileReadLine($OpenedTxtFile) If @error Then ExitLoop If StringInStr($Line, "invalid comm type") Then $Found = "Yes" $array = StringSplit($Line, ' ', 1) MsgBox(0, "", $array[3]) EndIf WEnd If $Found = "No" Then MsgBox(0, "Not found!", "AutoIt could not find the string you were searching for.") EndIf thanks. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 5, 2008 Moderators Share Posted June 5, 2008 http://www.autoitscript.com/forum/index.ph...st&p=382143if you want the 3 you would use 3-1So:$aSRE = StringRegExp...$ThirdWord = $aSRE[3 - 1]Etc...This way you only have to read the file once Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Zedna Posted June 5, 2008 Share Posted June 5, 2008 using the following codes i can't seem to read out the 3rd word in each line of the attached text file (log file) i believe my codes are right but it is just that it doesn't work for this text file particularly. what can i do? i need to read the 3rd (after , 7th and the word after "Invalid Comm Type". thanks. Your TXT file is TAB delimited (not space). Here is script for parsing: $Found = "No" ;~ $TxtFile = StringMid(@YEAR & @MON & @MDAY, 3) & ".txt" $TxtFile = "080606.txt" $data = FileRead($TxtFile) If @error Then MsgBox(48, "Error!", "File could not be opened. " & @CRLF _ & "1. Enter a valid path" & @CRLF _ & "2. Check if the file exists" & @CRLF _ & "3. Make sure you have access to the file" & @CRLF _ & "4. Check if the file is not opened by another program/script") Exit EndIf $data = StringSplit($data, @CRLF, 1) ; get array of lines TXT file For $i = 1 To $data[0] $Line = $data[$i] $array = StringSplit($Line, @TAB) ; get array of columns from each line If $array[0] > 11 And StringInStr($array[12], "invalid comm type") Then $Found = "Yes" MsgBox(0, "", $array[3]) EndIf Next If $Found = "No" Then MsgBox(0, "Not found!", "AutoIt could not find the string you were searching for.") EndIf Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
iceberg Posted June 5, 2008 Author Share Posted June 5, 2008 Got it! Thank you, SmOke_N! Appreciate your definition of the function. was simple and easy to understand. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
iceberg Posted June 5, 2008 Author Share Posted June 5, 2008 oops...i didnt realise that it was tab delimited. thanks Zedna! mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
iceberg Posted June 5, 2008 Author Share Posted June 5, 2008 if you had noticed there is a small rectangle is very line of the log file.i followed SmOke_N codes to remove that but it still didn't workhttp://www.autoitscript.com/forum/index.ph...st&p=227407I even tried StringStripCR....also the same problem.any other thoughts?thanks. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 5, 2008 Moderators Share Posted June 5, 2008 if you had noticed there is a small rectangle is very line of the log file.i followed SmOke_N codes to remove that but it still didn't workhttp://www.autoitscript.com/forum/index.ph...st&p=227407I even tried StringStripCR....also the same problem.any other thoughts?thanks.C'mon now, you've been here for some time ... What char is it? Copy it, then use MsgBox(64, "Your Mysterious Char", Asc(ClipGet())), now look up the ASCII value in the chart provided for you in your help file. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
iceberg Posted June 5, 2008 Author Share Posted June 5, 2008 apologies thanks for helping yet again. mouse not found....scroll any mouse to continue. 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