Jump to content

ReadLine until end of file? Help!


Recommended Posts

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

Link to comment
Share on other sites

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 :)

Link to comment
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]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...