roofninja Posted November 8, 2010 Posted November 8, 2010 I am having problems getting the correct output from this file that is generated by some other programs. The first line works perfectly, but the second line just gives me an "N". I want it to say "Latitude E5500" I have tried different variations of FileRead, FileReadLine, and _FileReadToArray without any success. For some reason in the ouput file, the line that is generated, has spaces between the letters and that is throwing me off. What am I doing wrong here? I have attached the output file. My brain has gone numb thinking about this. #include <String.au3> #Include <File.au3> $file1 = FileOpen(@ScriptDir&"\comp2.txt", 0) If $file1 = -1 Then MsgBox(0, "Error", "Unable to open comp.txt file.") Exit EndIf $01 = StringStripWS(FileReadLine($file1,1),8) $01 = StringTrimLeft($01,18) $02 = FileReadLine($file1,3) MsgBox(64,"","line 1_"&$01&@CRLF&@CRLF&"line 2_"&$02) RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!!
Realm Posted November 8, 2010 Posted November 8, 2010 Hello roofninja, I see a couple difficulties with this particular file. First, it has ASCII characters which hinder your filereading to string. Second, the line you are attempting to grab is actually on multiple lines. The data you you want is actually on line 5 with all the ASCII Cursor Returns an Linefeed characters. you can view how the file actually looks with Notepad++ or Scite. Lets use StringRegExpReplace() to filter out the characters we need. Again, use Scite or Notepad++ to view you file, in cases like this it will show you the hidden ASCII characters, and actual line formating. Try This: #include <String.au3> #Include <File.au3> $file1 = FileOpen(@ScriptDir&"\comp2.txt", 0) If $file1 = -1 Then MsgBox(0, "Error", "Unable to open comp.txt file.") Exit EndIf $01 = StringTrimLeft(StringStripWS(FileReadLine($file1,1),8),18) ; shortened your code by 1 line. $02= StringRegExpReplace(FileReadLine($file1,5), "[^\sa-zA-Z0-9òàùèéì]", "") ;note I changed the line to read MsgBox(64,"","line 1_"&$01&@CRLF&@CRLF&"line 2_"&$02) Tested and worked for me with the file provided. Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.
roofninja Posted November 8, 2010 Author Posted November 8, 2010 Thanks for the help. It makes since now. I didn't think to use that command. That worked. RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!!
Realm Posted November 8, 2010 Posted November 8, 2010 Thanks for the help.My pleasure, I had the time Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.
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