dar100111 Posted April 29, 2014 Share Posted April 29, 2014 (edited) Hey All! I was looking to know if this is possible by taking a for loop I have where I utilize the Ubound of my array and the count in my For..to...Step..Next Loop to build an accurate progress bar or status bar to show the progress? Thank you! For $i = 2 to $newArrayRowCount Step 1 ;TrayTip("10 Day Comparison", "Checking Row "&$i, 1000) $So = $arraynew[$i][2] $Priority = $arraynew[$i][35] $Rev = $arraynew[$i][39] $historicSoRowFound = _ArraySearch($arrayhistoric, $So) If @error Then $notFoundStart + 1 _2DArrayInsertRow($notFoundArray, $notFoundStart) $notFoundArray[$notFoundStart][0] = $So $notFoundArray[$notFoundStart][1] = $Priority $notFoundArray[$notFoundStart][2] = $Rev Else $oldPriority = $arrayhistoric[$historicSoRowFound][35] $oldRev = $arrayhistoric[$historicSoRowFound][39] If $oldPriority <> $Priority or $oldRev <> $Rev Then $exceptionStart + 1 _2DArrayInsertRow($exceptionArray, $exceptionStart) $exceptionArray[$exceptionStart][0] = $So $exceptionArray[$exceptionStart][1] = $oldPriority $exceptionArray[$exceptionStart][2] = $oldRev $exceptionArray[$exceptionStart][3] = $Priority $exceptionArray[$exceptionStart][4] = $Rev EndIf EndIf Next Edited April 29, 2014 by dar100111 Link to comment Share on other sites More sharing options...
JohnOne Posted April 29, 2014 Share Posted April 29, 2014 You should post a runnable example script. Quick look and I see two similar statements that don't do anything at all, and could be a source of some issue you may or may not be having. $notFoundStart + 1 and $exceptionStart + 1 If I were to guess, I'd say you want $notFoundStart += 1 and $exceptionStart += 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
dar100111 Posted April 29, 2014 Author Share Posted April 29, 2014 (edited) Hey John! Here's the whole script. It's working ok. I just have those starting at 1 with a global variable up top. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\Documents\Autoit scripts\EIflag.ico #AutoIt3Wrapper_Outfile=F:\EI\DFW\NAT\Oracle NMC\10 Day Tool\10daycheck.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.10.2 Author: myName Script Function: Compares 10 day values to flag new shipments on 10day_new. Checks for changes in priority and revenue and flags shipments. Creates Excel Document with tabs to reflect results from arrays. #ce ---------------------------------------------------------------------------- #include <Excel.au3> #include <Array.au3> #include <MsgBoxConstants.au3> Global $exceptionStart = 1 Global $notFoundStart = 1 Dim $exceptionArray[1][6] $exceptionArray[0][0] = "Exception SO" $exceptionArray[0][1] = "Old Priority" $exceptionArray[0][2] = "Old Revenue" $exceptionArray[0][3] = "New Priority" $exceptionArray[0][4] = "New Revenue" $exceptionArray[0][5] = "Region" Dim $notFoundArray[1][4] $notFoundArray[0][0] = "Not Found SO" $notFoundArray[0][1] = "Priority" $notFoundArray[0][2] = "Revenue" $notFoundArray[0][3] = "Region" Local $excel = _ExcelBookOpen("F:\EI\DFW\NAT\Oracle NMC\10 Day Tool\10day_old.xls") $arrayhistoric = _ExcelReadSheetToArray($excel) _ExcelBookClose($excel) Local $excel2 = _ExcelBookOpen("F:\EI\DFW\NAT\Oracle NMC\10 Day Tool\10day_new.xls") $arraynew = _ExcelReadSheetToArray($excel2) _ExcelBookClose($excel2) $newArrayRowCount = $arraynew[0][0] For $i = 2 to $newArrayRowCount Step 1 $arraynew[$i][2] = $arraynew[$i][2] &'-'& $arraynew[$i][3]&'-1' Next $historicArrayRowCount = $arrayhistoric[0][0] For $i = 2 to $historicArrayRowCount Step 1 $arrayhistoric[$i][2] = $arrayhistoric[$i][2] &'-'& $arrayhistoric[$i][3]&'-1' Next ProgressOn("10 Day Comparison", "Comparing Values") For $i = 2 to $newArrayRowCount Step 1 ;TrayTip("10 Day Comparison", "Checking Row "&$i, 1000) $So = $arraynew[$i][2] $Priority = $arraynew[$i][35] $Rev = $arraynew[$i][39] $region = $arraynew[$i][11] $historicSoRowFound = _ArraySearch($arrayhistoric, $So) If @error Then $notFoundStart + 1 _2DArrayInsertRow($notFoundArray, $notFoundStart) $notFoundArray[$notFoundStart][0] = $So $notFoundArray[$notFoundStart][1] = $Priority $notFoundArray[$notFoundStart][2] = $Rev $notFoundArray[$notFoundStart][3] = $region Else $oldPriority = $arrayhistoric[$historicSoRowFound][35] $oldRev = $arrayhistoric[$historicSoRowFound][39] If $oldPriority <> $Priority or $oldRev <> $Rev Then $exceptionStart + 1 _2DArrayInsertRow($exceptionArray, $exceptionStart) $exceptionArray[$exceptionStart][0] = $So $exceptionArray[$exceptionStart][1] = $oldPriority $exceptionArray[$exceptionStart][2] = $oldRev $exceptionArray[$exceptionStart][3] = $Priority $exceptionArray[$exceptionStart][4] = $Rev $exceptionArray[$exceptionStart][5] = $region EndIf EndIf Next ProgressOff() $oExcel = _ExcelBookNew(1) WinActivate($oExcel) _ExcelSheetAddNew($oExcel, "Not Found") _ExcelSheetActivate($oExcel, "Not Found") _ExcelWriteSheetFromArray($oExcel, $notFoundArray, 1,1,0,0) $oExcel.Columns.AutoFit _ExcelSheetAddNew($oExcel, "Exceptions") _ExcelSheetActivate($oExcel, "Exceptions") _ExcelWriteSheetFromArray($oExcel, $exceptionArray, 1,1,0,0) _ExcelSheetDelete($oExcel, "Sheet1") $oExcel.Columns.AutoFit Func _2DArrayInsertRow(ByRef $avArray, $iRow) If Not IsArray($avArray) Then Return SetError(1, 0, 0) If UBound($avArray, 0) <> 2 Then Return SetError(2, 0, 0) ; Add 1 row to the array Local $iUBoundRow = UBound($avArray) + 1 Local $iUBoundCol = UBound($avArray, 2) ReDim $avArray[$iUBoundRow][$iUBoundCol] ; Move all entries down until the specified position For $i = $iUBoundRow - 1 To $iRow + 1 Step -1 For $j = 0 To $iUBoundCol - 1 $avArray[$i][$j] = $avArray[$i - 1][$j] Next Next Return $iUBoundRow EndFunc ;==>_2DArrayInsertRow Edited April 29, 2014 by dar100111 Link to comment Share on other sites More sharing options...
JohnOne Posted April 29, 2014 Share Posted April 29, 2014 (edited) I cannot run your script because I don't have excel installed. Are you just wanting to know how to use ubound to calculate progress percentage? Global $Array[12345] $gui = GUICreate("gui") $progress = GUICtrlCreateProgress(10, 20, 300, 20) $button = GUICtrlCreateButton("button", 10, 60) GUISetState() Do $msg = GUIGetMsg() If $msg = $button Then _Func() EndIf Until $msg = -3 Func _Func() $size = UBound($Array) For $i = 1 To $size GUICtrlSetData($progress, ($i / $size) * 100) Next EndFunc ;==>_Func Something weird about this code. I get a beep before control has finished updating. Global $Array[12345] $gui = GUICreate("gui") $progress = GUICtrlCreateProgress(10, 20, 300, 20) $button = GUICtrlCreateButton("button", 10, 60) GUISetState() Do $msg = GUIGetMsg() If $msg = $button Then _Func() Beep(700,200) EndIf Until $msg = -3 Func _Func() $size = UBound($Array) For $i = 1 To $size GUICtrlSetData($progress, ($i / $size) * 100) Next EndFunc ;==>_Func Edited April 29, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
dar100111 Posted April 29, 2014 Author Share Posted April 29, 2014 (edited) Hey John, Figured it out actually. Just had to get my percentage of the row I'm on compared to total rows. Thanks for the help. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\Documents\Autoit scripts\EIflag.ico #AutoIt3Wrapper_Outfile=F:\EI\DFW\NAT\Oracle NMC\10 Day Tool\10daycheck.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.10.2 Author: myName Script Function: Compares 10 day values to flag new shipments on 10day_new. Checks for changes in priority and revenue and flags shipments. Creates Excel Document with tabs to reflect results from arrays. #ce ---------------------------------------------------------------------------- #include <Excel.au3> #include <Array.au3> #include <MsgBoxConstants.au3> Global $exceptionStart = 1 Global $notFoundStart = 1 Dim $exceptionArray[1][6] $exceptionArray[0][0] = "Exception SO" $exceptionArray[0][1] = "Old Priority" $exceptionArray[0][2] = "Old Revenue" $exceptionArray[0][3] = "New Priority" $exceptionArray[0][4] = "New Revenue" $exceptionArray[0][5] = "Region" Dim $notFoundArray[1][4] $notFoundArray[0][0] = "Not Found SO" $notFoundArray[0][1] = "Priority" $notFoundArray[0][2] = "Revenue" $notFoundArray[0][3] = "Region" Local $excel = _ExcelBookOpen("F:\EI\DFW\NAT\Oracle NMC\10 Day Tool\10day_old.xls") $arrayhistoric = _ExcelReadSheetToArray($excel) _ExcelBookClose($excel) Local $excel2 = _ExcelBookOpen("F:\EI\DFW\NAT\Oracle NMC\10 Day Tool\10day_new.xls") $arraynew = _ExcelReadSheetToArray($excel2) _ExcelBookClose($excel2) $newArrayRowCount = $arraynew[0][0] For $i = 2 to $newArrayRowCount Step 1 $arraynew[$i][2] = $arraynew[$i][2] &'-'& $arraynew[$i][3]&'-1' Next $historicArrayRowCount = $arrayhistoric[0][0] For $i = 2 to $historicArrayRowCount Step 1 $arrayhistoric[$i][2] = $arrayhistoric[$i][2] &'-'& $arrayhistoric[$i][3]&'-1' Next $a = 1/$newArrayRowCount $b = UBound($arraynew) - 1 ProgressOn("10 Day Comparison", "Comparing Values", "0%") For $i = 2 to $newArrayRowCount Step 1 $a = int(($i / $newArrayRowCount)*100) ProgressSet($a, $a & " % of "&$b&" rows processed.") ;TrayTip("10 Day Comparison", "Checking Row "&$i, 1000) $So = $arraynew[$i][2] $Priority = $arraynew[$i][35] $Rev = $arraynew[$i][39] $region = $arraynew[$i][11] $historicSoRowFound = _ArraySearch($arrayhistoric, $So) If @error Then $notFoundStart + 1 _2DArrayInsertRow($notFoundArray, $notFoundStart) $notFoundArray[$notFoundStart][0] = $So $notFoundArray[$notFoundStart][1] = $Priority $notFoundArray[$notFoundStart][2] = $Rev $notFoundArray[$notFoundStart][3] = $region Else $oldPriority = $arrayhistoric[$historicSoRowFound][35] $oldRev = $arrayhistoric[$historicSoRowFound][39] If $oldPriority <> $Priority or $oldRev <> $Rev Then $exceptionStart + 1 _2DArrayInsertRow($exceptionArray, $exceptionStart) $exceptionArray[$exceptionStart][0] = $So $exceptionArray[$exceptionStart][1] = $oldPriority $exceptionArray[$exceptionStart][2] = $oldRev $exceptionArray[$exceptionStart][3] = $Priority $exceptionArray[$exceptionStart][4] = $Rev $exceptionArray[$exceptionStart][5] = $region EndIf EndIf Next ProgressOff() $oExcel = _ExcelBookNew(1) WinActivate($oExcel) _ExcelSheetAddNew($oExcel, "Not Found") _ExcelSheetActivate($oExcel, "Not Found") _ExcelWriteSheetFromArray($oExcel, $notFoundArray, 1,1,0,0) $oExcel.Columns.AutoFit _ExcelSheetAddNew($oExcel, "Exceptions") _ExcelSheetActivate($oExcel, "Exceptions") _ExcelWriteSheetFromArray($oExcel, $exceptionArray, 1,1,0,0) _ExcelSheetDelete($oExcel, "Sheet1") $oExcel.Columns.AutoFit Func _2DArrayInsertRow(ByRef $avArray, $iRow) If Not IsArray($avArray) Then Return SetError(1, 0, 0) If UBound($avArray, 0) <> 2 Then Return SetError(2, 0, 0) ; Add 1 row to the array Local $iUBoundRow = UBound($avArray) + 1 Local $iUBoundCol = UBound($avArray, 2) ReDim $avArray[$iUBoundRow][$iUBoundCol] ; Move all entries down until the specified position For $i = $iUBoundRow - 1 To $iRow + 1 Step -1 For $j = 0 To $iUBoundCol - 1 $avArray[$i][$j] = $avArray[$i - 1][$j] Next Next Return $iUBoundRow EndFunc ;==>_2DArrayInsertRow Edited April 29, 2014 by dar100111 Link to comment Share on other sites More sharing options...
JohnOne Posted April 29, 2014 Share Posted April 29, 2014 Ace. But you really should take a closer look at those statements I mentioned earlier, they probably are not doing what you might be thinking they should. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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