MSLx Fanboy Posted April 11, 2005 Posted April 11, 2005 I'm probably making this too difficult for myself, but... I'm writing a program that cleans and hides directories. What I want to do is have a special file that lists directories other than the default that it should work with as well. Any time I try to run this script, it returns '0' for the line number. I can't figure out why, the file exists, and there is multiple lines of text. I had a version working earlier, but had way to much code, and waited for errors to happen before it finished reading the file... Any help is greatly appreciated. Thanks! #include<file.au3> $list = "dir.txt" If FileExists($list) <> 1 Then Exit $file = FileOpen($list, 0) If $file = -1 Then Exit MsgBox(0, "file name", $list) $lines = _FileCountLines($file) MsgBox(0, "testing", "there are " & $lines & " lines.") Dim $contents[($lines + 1)] For $x = 1 To $lines $contents[$x] = FileReadLine($file, $x) Next FileClose($file) $size = UBound($contents) - 1 Msgbox(0, "testing", "The size is " & $lines & " and according to the array: " & $size) For $x = 1 to $size MsgBox(0, "lines read", $contents[$x]) Next Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
Ejoc Posted April 11, 2005 Posted April 11, 2005 Could use: $contents = _FileReadToArray("dir.txt") Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
MSLx Fanboy Posted April 11, 2005 Author Posted April 11, 2005 nevermind, I kept working with it, finally came up with: #include <File.au3> Func FileLines($fname) Dim $contents If FileExists($fname) = 0 Then Exit $file = FileOpen($fname, 0) If $file = -1 Then Exit _FileReadToArray($fname, $contents) FileClose($fname) return $contents EndFunc;;FileLines() $file = FileLines("dir.txt") For $x = 1 To (UBound($file) - 1) MsgBox(0, "final output", $file[$x]) Next Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
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