darkshadow791 Posted April 25, 2007 Share Posted April 25, 2007 This is a really simple question with a possibly very simple question that I probably should know but don't, so I'm posting here. The following code gives me very weird numbers and values for $percent... "1.#INF" Local $temp = _FileCountLines("Definitions.txt") Local $percent = 0 Local $perc = GUICtrlCreateProgress(0,(450/2)-(40/2),500,40) Local $lab = GUICtrlCreateLabel("Updating definitions...",(500/2) - 100,100,200,20) GUICtrlSetData($perc,$percent) For $count = 1 To $temp Step 1 ;MsgBox(0,"",($count / $temp)) $percent = (($count / $temp) * 100.0) GUICtrlSetData($perc,$percent) Local $temp = StringSplit(FileReadLine("Definitions.txt",$count),"|") $List[$count][1] = $temp[1] $List[$count][2] = $temp[2] ;Sleep(100) Next GUICtrlDelete($perc) GUICtrlDelete($lab) Made with a simple textfile called definitions.txt that has lines of random txt with a "|" between them. The error occurs when $percent is being redefined in the for loop... And it makes my progressbar do weird things.... Note Taker Lite - a note taking / converting tool. Link to comment Share on other sites More sharing options...
therks Posted April 25, 2007 Share Posted April 25, 2007 (edited) MsgBox(0, 'Divide by zero!', 1 / 0) = 1.#INFSomewhere you're dividing by zero. I would be sure to check that $temp variable before throwing it into an equation.Er whoa, wait, you're redefining temp within the for loop, that's why.Watch what happens when I do this:$toNum = 5 For $count = 1 to $toNum ConsoleWrite($count & ', ' & $toNum & @CRLF) $toNum = 0 NextoÝ÷ Øë¦ëlr^×´ßN4çOÜ¡×v+@Øî²Ø§q«ÊÙ÷öÚÞjX³y©Ú®¶²zö¥¹«^²Ú3zº0éî±çb©¶¦jØjW±¦·¬²*'殶sdFÒb33c¶W³Ð¤×6t&÷Âb33²b33²Ã²b33c¶W²Ò*Edit2: Just had to mention, the Step 1 in your For loop is redundant. It steps by 1 by default. Edited April 25, 2007 by Saunders My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Gabburd Posted April 25, 2007 Share Posted April 25, 2007 The problem stemmed from the reuse of your variable $temp Try this: #include <file.au3> Local $temp = _FileCountLines("Definitions.txt") Local $percent = 0 Local $perc = GUICtrlCreateProgress(0,(450/2)-(40/2),500,40) Local $lab = GUICtrlCreateLabel("Updating definitions...",(500/2) - 100,100,200,20) GUICtrlSetData($perc,$percent) For $count = 1 To $temp Step 1 Local $temp2 = StringSplit(FileReadLine("Definitions.txt",$count),"|") MsgBox(0,"",($count / $temp)) $percent = (($count / $temp) * 100.0) GUICtrlSetData($perc,$percent) Local $List[$count+1][3] $List[$count][1] = $temp2[1] $List[$count][2] = $temp2[2] ;Sleep(100) Next GUICtrlDelete($perc) GUICtrlDelete($lab) Link to comment Share on other sites More sharing options...
darkshadow791 Posted April 25, 2007 Author Share Posted April 25, 2007 (edited) Hahaha, I can't believe I didn't see that before. Thanks Edit: I know step 1 is redundant, I just like doing it anyway (OCD) Edited April 25, 2007 by darkshadow791 Note Taker Lite - a note taking / converting tool. 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