Sign in to follow this  
Followers 0
Aeterna

ReadLine until end of file? Help!

4 posts in this topic

I'm trying to read every line of 2 different files, and put the value of each line into 2 respective arrays. This is my guess at it, but I think its just looping forever. Any solutions?

CODE
Local $Follows[1000]

Local $Accounts[1000]

$AccountFile = "c:\accounts.txt"

$FollowFile = "c:\follows.txt"

$line = 1

While $Line > 0

$follow = fileReadLine($FollowFile, $line)

_ArrayAdd($Follows, $follow)

$account = fileReadLine($AccountFile, $line)

_ArrayAdd($Accounts, $account)

$line = $line + 1

WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Why not use _FileReadToArray included in "File.au3"?

This function will read your entire file to an array, every line in a separate element.

#include <File.au3>
#include <Array.au3>

Dim $Follows, $Accounts

$AccountFile = "c:\accounts.txt"
$FollowFile = "c:\follows.txt"
_FileReadToArray($FollowFile, $Follows)
_FileReadToArray($AccountFile, $Accounts)

_ArrayDisplay($Follows)
_ArrayDisplay($Accounts)
Edited by enaiman

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

And that sounds right.

You set $line to = 1 before the loop which is good and then increment $line each iteration of the loop, thus $line is always going to be > 0.

You will want to check when you are and the end of the file. Check @error for that condition - the help file explains it and gives an example.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

thanks, solved ^_^

got another question gonna be posting it in a new thread.

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