Tigerweld Posted February 18, 2008 Share Posted February 18, 2008 I'm trying to load a file from an ini file. The ini read works, but after that it just freezes. Can someone look at this and tell me what I have wrong? dim $line, $file, $var $var = IniRead("C:\bi\backuppaths.ini", "paths", "path1", "NotFound") ;MsgBox(4096, "Result", $var) FileOpen($var & "Backup0215200002.log", 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 if StringInStr($line,'backup success') Then MsgBox(4096, "Backup", "Backup Successful") WEnd fileclose($var) Link to comment Share on other sites More sharing options...
Valuater Posted February 18, 2008 Share Posted February 18, 2008 You are missing $File $File = FileOpen($var & "Backup0215200002.log", 0) ... also depending on your info $File = FileOpen($var & "\Backup0215200002.log", 0) ; added a slash "\" 8) Link to comment Share on other sites More sharing options...
Tigerweld Posted February 18, 2008 Author Share Posted February 18, 2008 GRRR! Thanks man. Here is a tougher one for you. That backup file name actually will change every day the sceduled task runs, although the name will always start with 'backup' in the beginning. I would like to be able to open the newest file with 'backup*.log' and use that one. Any ideas? Would I need an array? (little over my head at the moment) Link to comment Share on other sites More sharing options...
MHz Posted February 18, 2008 Share Posted February 18, 2008 I will go along with Valuaters' bug fix and I will pick on the file handle bug. Get the handle and close it. Some more error checking would be nice if you can add.dim $line, $file, $var$var = IniRead("C:\bi\backuppaths.ini", "paths", "path1", "NotFound");MsgBox(4096, "Result", $var)$handle_read = FileOpen($var & "\Backup0215200002.log", 0);Check if file opened for reading OKIf $handle_read = -1 ThenMsgBox(0, "Error", "Unable to open file.")ExitEndIf; Read in lines of text until the EOF is reachedWhile 1$line = FileReadLine($handle_read)If @error = -1 Then ExitLoopif StringInStr($line,'backup success') Then MsgBox(4096, "Backup", "Backup Successful")WEndfileclose($handle_read) Link to comment Share on other sites More sharing options...
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