Sign in to follow this  
Followers 0
gordo

_filereadtoarray including linefeeds

5 posts in this topic

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

Share this post


Link to post
Share on other sites



I'm using _fileradtoarray to parse a simple text file I created

when you create this .txt file can you use

FileWrite ( filehandle or "filename", "line" )

Parameters

filehandle 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


NEWHeader1.png

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by gordo

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0