gordo Posted July 7, 2005 Posted July 7, 2005 I'm using _fileradtoarray to parse a simple text file I created. When reading the file into an array, it's clearly recognizing each new line by the carriage return character, but it's also adding this character to each array value. How do I prevent this from happening? You can recreate this effect by creating a file in Notepad called c:\test.txt with several lines of [Enter] delimited text. Then run this script and you can see that the array value gets the carriage return added: #include <file.au3> Dim $array If Not _FileReadToArray("c:\test.txt",$array) Then MsgBox(4096,"Error", " Error reading file:" & @error) Exit EndIf While 1 If WinActive("Untitled - Notepad") Then ControlClick("Untitled - Notepad", "", 15) Send($array[1]) EndIf sleep(1000) WEnd
Valuater Posted July 7, 2005 Posted July 7, 2005 I'm using _fileradtoarray to parse a simple text file I createdwhen you create this .txt file can you useFileWrite ( filehandle or "filename", "line" )Parametersfilehandle The handle of a file, as returned by a previous call to FileOpen. Alternatively, you may use a string filename as the first parameter. line The line of text to write to the text file. The line is written as is - no @CR or @LF characters are added. ****** important part ***hope it helps
gordo Posted July 7, 2005 Author Posted July 7, 2005 I'm not creating or writing to the file in my script, I'm just trying to parse an existing, manually created file, so I don't think the FileWrite command would help. Thanks anyway.
Valuater Posted July 7, 2005 Posted July 7, 2005 since you are reading a line at a time, cant you just read the file lines into a $String or do you have a purpose for ther array? 8)
gordo Posted July 7, 2005 Author Posted July 7, 2005 (edited) I suppose that's the answer... I was hoping to use an array for simplicity's sake, but it looks as if that filereadarray function is just too limited for my needs. Edited July 7, 2005 by gordo
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