dar100111 Posted December 13, 2013 Posted December 13, 2013 (edited) Hey All, Here is my code attached. I feel like I'm doing something simple that's wrong. I seem to have all the other pieces working so far except finding all my unique rows so I can pull all the data from my origin array which is $aArray. I am making a script so that eventually I can take the data and combine appropriate shipment info to the branches I'm trying to send them too. Can't quite put my finger on why I can't find all the instances and my _ArrayDisplay($found) doesn't pop up. My excel sheet is attached as well. Thanks in advance if anyone has any ideas. expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: Daniel Rowe Script Function: Mass Email Tool #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <INet.au3> #include <excel.au3> #include <array.au3> #include <OutlookEX.au3> Global $oOutlook = _OL_Open() $automatednote = @lf&"****PLEASE NOTE THIS EMAIL IS AUTOGENERATED FROM ORACLE NMC****" $startrow = 2;startrow to pull data excluding header from excel tool Func _CreateEmailfromUniqueArray($p_array_to_loop, $p_array_to_search, $p_emailbody) $searchcount = UBound($p_array_to_loop) - 1 $columncounter = $p_array_to_search[0][1] For $i = 1 To $searchcount Step 1 $podoffice = $p_array_to_loop[$i] MsgBox("", "", $podoffice) $found = _ArrayFindAll($p_array_to_search, $podoffice, 0, 0, 0, 1) _ArrayDisplay($found);;not showing up yet $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject="&$subjectline&" for "&$podoffice) $oItem.BodyFormat = $olFormatPlain $oItem.GetInspector $sBody = $oItem.Body $oItem.Body = $emailbody &$found&@lf& $sBody &@lf&$automatednote $oItem.Display Next EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;Start $missingpodsubject = "Missing Oracle POD's" $template = InputBox("Mass Email", "Select Template"&@lf&@lf&"1. Missing POD's"&@lf&"2. ..."&@lf&"3. ..."&@lf&"4. ..."&@lf&"5. Custom Template","", "", 200, 220) If @error = 1 Then Exit If $template = 1 Then $subjectline = $missingpodsubject $emailbody = "Please update POD's into expo for following shipments"&@lf&@lf EndIf If $template = 2 Then Exit If $template = 3 Then Exit If $template = 4 Then Exit If $template = 5 then #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Enter Email Body", 610, 438, 192, 124) $Label1 = GUICtrlCreateLabel("Enter Email Body Below", 56, 16, 497, 41, BitOR($SS_CENTER,$SS_CENTERIMAGE,$SS_SUNKEN)) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") $body = GUICtrlCreateEdit("", 24, 110, 561, 240) $Button1 = GUICtrlCreateButton("Finish", 216, 368, 185, 57) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Do $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $emailbody = ControlGetText("", "", $body) $Button1 = 1 EndSwitch Until $Button1 = 1 EndIf ;;;;execute results of template select $oExcel = _ExcelBookOpen( @ScriptDir & "\Missing POD template.xlsx") $aArray = _ExcelReadSheetToArray($oExcel);This will contail all the info to send to the branches $1darray = _ExcelReadArray($oExcel, 2, 1,UBound($aArray) - 2, 1) _ArrayDisplay($aArray) _ArrayDisplay($1darray) $resultsarray = _ArrayUnique($1darray);build an array to have 1 row for each unique branch _ArrayDisplay($resultsarray) _CreateEmailfromUniqueArray($resultsarray, $aArray, $emailbody) Missing POD template.xlsx Edited December 13, 2013 by dar100111
JohnOne Posted December 13, 2013 Posted December 13, 2013 In scite Tools-> Trace add TraceLines check errors AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
dar100111 Posted December 13, 2013 Author Posted December 13, 2013 Hey John! So I did that and came back with this. Where do I find the errors related? Thanks! @@ Trace(46) : $found = _ArrayFindAll($p_array_to_search, $podoffice, 0, 0, 0, 1) >Error code: 6 @@ Trace(48) : _ArrayDisplay($found) >Error code: 1
BugFix Posted December 13, 2013 Posted December 13, 2013 @@ Trace(46) : $found = _ArrayFindAll($p_array_to_search, $podoffice, 0, 0, 0, 1) >Error code: 6 See in the help file: 6 - $vValue was not found in array So you know: the searched value doesn't exists. Best Regards BugFix
JohnOne Posted December 13, 2013 Posted December 13, 2013 @@ Trace(48) : _ArrayDisplay($found) >Error code: 1 And that means $found is not an array. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
dar100111 Posted December 13, 2013 Author Posted December 13, 2013 Hmm. Very interesting. That does help explain the problem. What still baffles me is the value that's being searched for is coming directly out of that $aArray in the first place. I think I'm having it search for a substring I believe in the function with the 1 at the end of the function line. Does this seem off or maybe something in the way I'm doing my code is causing the issue? Thanks for the help! I'll keep brainstorming as well.
JohnOne Posted December 13, 2013 Posted December 13, 2013 Are these displaying? ;;;;execute results of template select $oExcel = _ExcelBookOpen( @ScriptDir & "\Missing POD template.xlsx") $aArray = _ExcelReadSheetToArray($oExcel);This will contail all the info to send to the branches $1darray = _ExcelReadArray($oExcel, 2, 1,UBound($aArray) - 2, 1) _ArrayDisplay($aArray) _ArrayDisplay($1darray) $resultsarray = _ArrayUnique($1darray);build an array to have 1 row for each unique branch _ArrayDisplay($resultsarray) _CreateEmailfromUniqueArray($resultsarray, $aArray, $emailbody) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
dar100111 Posted December 16, 2013 Author Posted December 16, 2013 Hey John! Sorry for the late response. Yes the array's are displaying all except the final array display in my function where it's getting the error. I've been wondering if there were some weird error in the data from the unique array that I'm not considering, but since it's being pulled from the other array's I'm having a hard time pointing at the issue. In my sheet the first instance that it's looping through is the value "DFW" which is what it's showing on my msgbox for $podoffice properly. In the function I'm telling it to search through $p_array_to _search for my that value which it's originally pulled from. Could it be possible that my function is throwing it off? Thanks. $oExcel = _ExcelBookOpen( @ScriptDir & "\Missing POD template.xlsm") $aArray = _ExcelReadSheetToArray($oExcel);This will contail all the info to send to the branches $1darray = _ExcelReadArray($oExcel, 2, 1,UBound($aArray) - 2, 1) _ArrayDisplay($aArray) _ArrayDisplay($1darray) $resultsarray = _ArrayUnique($1darray);build an array to have 1 row for each unique branch _ArrayDisplay($resultsarray) _CreateEmailfromUniqueArray($resultsarray, $aArray, $emailbody) Func _CreateEmailfromUniqueArray($p_array_to_loop, $p_array_to_search, $p_emailbody) $searchcount = UBound($p_array_to_loop) - 1 $columncounter = $p_array_to_search[0][1] For $i = 1 To $searchcount Step 1 $podoffice = StringLeft($p_array_to_loop[$i],3) MsgBox("", "", $podoffice) $found = _ArrayFindAll($p_array_to_search, $podoffice, 0, 0, 0, 1) _ArrayDisplay($found);;not showing up yet $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject="&$subjectline&" for "&$podoffice) $oItem.BodyFormat = $olFormatPlain $oItem.GetInspector $sBody = $oItem.Body $oItem.Body = $emailbody &$found&@lf& $sBody &@lf&$automatednote $oItem.Display Next EndFunc
JohnOne Posted December 16, 2013 Posted December 16, 2013 Perhaps the string you are searching for is in [1] I'm not 100% but I think _ArrayFindAll() might only search 1 column, so try adding the last parameter (7th) as 1. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Solution dar100111 Posted December 16, 2013 Author Solution Posted December 16, 2013 Hey John! I figured it out and it was something silly. I wasn't doing the find all function correctly. I changed to $found = _ArrayFindAll($p_array_to_search, $podoffice, 0,0,0,1,1) and it is now displaying the $found array properly. Thank you for all helping me look at this. I just needed to take a break over the weekend to come back fresh at it. Thanks again!
JohnOne Posted December 16, 2013 Posted December 16, 2013 Ace. If the target might be in either then loop it twice. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
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