Sign in to follow this  
Followers 0
R0B45

Reading text file to variable

4 posts in this topic

Im quite new, and I was just wondering the possibility of reading a text file line by line into a single variable.

After each iteration the variable reads the next line in the text file based on a counter. If this is possible, suggestions or the code would be awesome.

Thanks

Share this post


Link to post
Share on other sites



Check out "FileReadLine" in the manual. It may be exactly what you want =]

CODE
a$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

MsgBox(0, "Line read:", $line)

Wend

FileClose($file)

Share this post


Link to post
Share on other sites

FileReadLine seem the obvious choice but you might consider also _FileReadToArray included into File.au3 UDF

That one will read all the content of the file into an array, each array element being a text line.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

"" &_


What is what? What is what.

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