Aeterna Posted April 17, 2009 Posted April 17, 2009 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? CODELocal $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
enaiman Posted April 17, 2009 Posted April 17, 2009 (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 April 17, 2009 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 :)
bo8ster Posted April 17, 2009 Posted April 17, 2009 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]
Aeterna Posted April 17, 2009 Author Posted April 17, 2009 thanks, solved got another question gonna be posting it in a new thread.
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