vinnyMS Posted July 19, 2021 Share Posted July 19, 2021 i have this script that i need a progress bar about #Include <Array.au3> #Include <Debug.au3> #include <Constants.au3> $s = FileRead("book.txt") Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next _ArraySort($w, 1, 0, 0, 1) _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) ; _DebugArrayDisplay($w, "Title", "|0:1") ; _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) plz help Link to comment Share on other sites More sharing options...
MattHiggs Posted July 20, 2021 Share Posted July 20, 2021 (edited) This is how I normally write my progress bars: #Include <Array.au3> #Include <Debug.au3> #include <Constants.au3> $s = FileRead("book.txt") Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) ProgressOn ( "Starting up", "Loading", "Loading", Default, Default, 18 ) For $i = 0 to UBound($w)-1 ProgressSet ( ( $i / (UBound ( $w ) - 1) ) * 100, "text to show item being processed", "main text" ) StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next _ArraySort($w, 1, 0, 0, 1) _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) ProgressOff () ; _DebugArrayDisplay($w, "Title", "|0:1") ; _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) Edited July 20, 2021 by MattHiggs Link to comment Share on other sites More sharing options...
JockoDundee Posted July 20, 2021 Share Posted July 20, 2021 @MattHiggs, if the sort takes time, won’t the bar be stuck at 100% for that long? Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
MattHiggs Posted July 20, 2021 Share Posted July 20, 2021 @JockoDundeeWhere you put the "progressoff" is up to you. I figured you just needed some help with the logic of setting the progress bar. You can put it before the _arraysort if you so choose. Link to comment Share on other sites More sharing options...
MattHiggs Posted July 20, 2021 Share Posted July 20, 2021 Or is it that you want to the progress bar to calculate progress of the _arraysort? That would not be possible unless you and modify the Array.au3 udf in the autoit includes folder. Link to comment Share on other sites More sharing options...
Solution Subz Posted July 20, 2021 Solution Share Posted July 20, 2021 You could use SplashTextOn to display the text as it's being processed, things like FileRead and StringRegExp could take several seconds to complete before the progress even started. Basic example: #Include <Array.au3> #Include <Debug.au3> #include <Constants.au3> Example() Func Example() Local $sTitle = "Example Project" Local $sFilePath = @ScriptDir & "\Example.txt" SplashTextOn($sTitle, "Reading : " & $sFilePath, 300, 50) Local $s = FileRead($sFilePath) ControlSetText($sTitle, "", "Static1", "Processing : " & $sFilePath) Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended ControlSetText($sTitle, "", "Static1", $i & " of " & UBound($w)-1) Next ControlSetText($sTitle, "", "Static1", "Sorting Array") _ArraySort($w, 1, 0, 0, 1) SplashOff() _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) EndFunc ;==>Example Link to comment Share on other sites More sharing options...
vinnyMS Posted July 20, 2021 Author Share Posted July 20, 2021 (edited) is it possible to add the progress bar and make it work for each array row result counting min/max rows completed Edited July 20, 2021 by vinnyMS Link to comment Share on other sites More sharing options...
vinnyMS Posted July 20, 2021 Author Share Posted July 20, 2021 #Include <Array.au3> #Include <Debug.au3> #include <Constants.au3> #include <AutoItConstants.au3> Example() Func Example() $s = FileRead("2.txt") ProgressOn("word frequency", "Increments every row", "0%", -1, -1, BitOR($DLG_NOTONTOP, $DLG_MOVEABLE)) Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended ProgressSet($i, $i & "%") Next _ArraySort($w, 1, 0, 0, 1) _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) ProgressSet(100, "Done", "Complete") ; _DebugArrayDisplay($w, "Title", "|0:1") ; _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) ProgressOff() EndFunc ;==>Example i almost got it working with a minor bug in percent value how to fix it? Link to comment Share on other sites More sharing options...
JockoDundee Posted July 20, 2021 Share Posted July 20, 2021 Because you changed what Matt had, which was the rows/total rows, not just the rows. Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
vinnyMS Posted July 20, 2021 Author Share Posted July 20, 2021 (edited) i tried it again, it works with less content, if there's thousands of words it doesn't show progress it says "not responding" for many minutes here's what i have #Include <Array.au3> #Include <Debug.au3> #include <Constants.au3> #include <AutoItConstants.au3> Example() Func Example() $s = FileRead("book.txt") ProgressOn ( "Word Frequency", "Counting", "Loading", Default, Default, 18 ) Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 ProgressSet (( $i/(UBound($w) - 1)) * 100, "processed", "word frequency" ) StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next _ArraySort($w, 1, 0, 0, 1) _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) ; _DebugArrayDisplay($w, "Title", "|0:1") ; _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) ProgressOff() EndFunc ;==>Example Edited July 20, 2021 by vinnyMS Link to comment Share on other sites More sharing options...
Subz Posted July 20, 2021 Share Posted July 20, 2021 Explained that in my code above (did you test),. Link to comment Share on other sites More sharing options...
vinnyMS Posted July 20, 2021 Author Share Posted July 20, 2021 it works, freezes for 10 seconds but loads 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