dajesterofdeath Posted July 5, 2011 Share Posted July 5, 2011 Hi guys, I'm new to autoit, and I'm struggling with arrays. the break down, I have a folder with audio files in it. the file names are in the format of date_time_customernumber.mp3 every time someone calls a client it records the conversation into this folder with the above format, therefore, there can be multiple audio files for the one client. what I am trying to achieve is to search the folder for all audio files with a particular clients number in the file name and write these to an array then select the largest file of them all. once it has achieved this I want to be able to open the audio file. the code I have so far Case $msg = $button4 $var4 = GUICtrlRead($input2);this is the date the call was made $var10 = guictrlread($Input5);this is the clients number ;msgbox(1,"","Y:\archive\"& Stringright($var4,4) & "-" & stringleft(stringright($var4,7),2)& "\W" & _WeekNumberISO($var4) -2 & "\"& stringleft($var4,2) & "\*" & "0746652227" & ".*");this converts the date the call was made to the format of our archive $search = FileFindFirstFile("Y:\archive\"& Stringright($var4,4) & "-" & stringleft(stringright($var4,7),2)& "\W" & _WeekNumberISO($var4) & "\"& stringleft($var4,2) & "\*" & $var10 & "*.*") for $i = 0 to 10 $file = ("Y:\archive\"& Stringright($var4,4) & "-" & stringleft(stringright($var4,7),2)& "\W" & _WeekNumberISO($var4) -2 & "\"& stringleft($var4,2) & "\" & FileFindNextFile($search)) If @error Then ExitLoop Local $myarray[10][2] $myarray[$i][0] = "Y:\archive\"& Stringright($var4,4) & "-" & stringleft(stringright($var4,7),2)& "\W" & _WeekNumberISO($var4) -2 & "\"& stringleft($var4,2) & "\" & $file $myarray[$i][1] = FileGetSize($file) _ArrayDisplay($myarray) Issues I'm having: it is finding all instances however showing them in separate array display boxes, eg shows array line 0 with value then when i close the array display window it pops up another array display window with the next search result in array line 1 2nd issue im not sure how to find the largest file, I have attempted with the _arraymaxindex but my msg box of MsgBox(0,"", _ArrayMaxIndex($myarray, 1, 1)) gives me a result of -1 any thoughts on this matter? Link to comment Share on other sites More sharing options...
JohnOne Posted July 5, 2011 Share Posted July 5, 2011 There is not enough code to give a considered answer, but I will tell you the answer to your first issue, is most likely because your _ArrayDisplay() function is inside a loop. 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...
czardas Posted July 5, 2011 Share Posted July 5, 2011 (edited) You could sort the array on the second column to put them in order of file size. _ArraySort($myarray, 1, 0, 0, 1) _ArrayMaxIndex only works on a 1 dimensional array, which is why you are getting an error return value of -1. Edited July 5, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jaberwacky Posted July 5, 2011 Share Posted July 5, 2011 (edited) Your for loop makes eleven iterations yet your array has ten elements. How are you not getting an array out of bounds error?Can you give me an example of the date and a client number so that I can plug them into this to observe your issues myself?Scratch that -- I back wards reversificatided it myselfactually I might still need an example of your date format. Edited July 5, 2011 by LaCastiglione Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
dajesterofdeath Posted July 6, 2011 Author Share Posted July 6, 2011 (edited) I have moved my Array Display outside the loop, however now it is not pulling the right data. for example it is now pulling it in this format [2]|Y:\archive\2011-06\W26\29\Y:\archive\2011-06\W26\29\|0 which instead of putting the location then filename in the array it is putting the location then the location again. when previously while it was in the loop it was giving [0]|Y:\archive\2011-06\W26\29\Y:\archive\2011-06\W26\29\20110629-093857_10754826194.wav|1042140 but putting it into 2 array displays. clearly im doing something wrong. the full code is below. basically i am making a Call Quality tool where i listen to an agents outbound call and mark it accordingly. at this point i havent set up the marking system, im just focused on it finding the call and playing it. expandcollapse popup;call quality system #include <ButtonConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <array.au3> #include <Date.au3> Hotkeyset("{ESC}","terminate") Func terminate() exit endfunc _Main() Func _Main() local $msg, $Button3 $var1 = @MDAY & "/" & @MON & "/" & @YEAR ;For $date field $Form1 = GUICreate("BSmart Call Quality", 434, 401, 683, 525) $Label2 = GUICtrlCreateLabel("Agent Name:", 24, 72, 66, 17) $Input2 = GUICtrlCreateDate("", 340, 40, 83, 21,$WS_TABSTOP) $Label1 = GUICtrlCreateLabel("CQ Agent:", 24, 48, 53, 17) $Combo = GUICtrlCreateCombo("CQ Agent", 104, 40, 121, 21) GUICtrlSetData(-1,"agent1|agent2|agent3", "CQ Agent") $Label2 = GUICtrlCreateLabel("Agent Name:", 24, 72, 66, 17) $Input3 = GUICtrlCreateInput("", 104, 64, 121, 21) $Label3 = GUICtrlCreateLabel("Sale Date:", 270, 48, 54, 17) $Label4 = GUICtrlCreateLabel("Date of CQ:", 270, 72, 60, 17) $Input4 = GUICtrlCreateInput($var1, 340, 64, 83, 21) $Label5 = GUICtrlCreateLabel("Client Number:", 24, 96, 73, 17) $Input5 = GUICtrlCreateInput("", 104, 88, 121, 21) $Checkbox1 = GUICtrlCreateCheckbox("Script Followed", 8, 120, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("Stated Free", 112, 120, 97, 17) $Button3 = GUICtrlCreateButton("Get Client Data", 332, 135, 95, 25) $Button4 = GUICtrlCreateButton("Get Agent Call", 332, 105, 95, 25) $Quality = GUICtrlCreateTab(8, 144, 417, 217) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("Phone Manner") $Checkbox3 = GUICtrlCreateCheckbox("Friendly", 16, 176, 57, 17) $Checkbox4 = GUICtrlCreateCheckbox("Clear", 16, 192, 41, 17) $Checkbox5 = GUICtrlCreateCheckbox("Excited", 128, 176, 57, 17) $Checkbox6 = GUICtrlCreateCheckbox("Professional", 128, 192, 81, 17) $Checkbox7 = GUICtrlCreateCheckbox("Rapport/Creates Interest", 256, 176, 145, 17) $Editbox1 = GUICtrlCreateEdit("", 16, 256, 401, 97, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN)) $Label6 = GUICtrlCreateLabel("Comments", 16, 232, 53, 17) $TabSheet2 = GUICtrlCreateTabItem("Customer Details") $Checkbox8 = GUICtrlCreateCheckbox("Full Names and Spelling", 16, 176, 129, 17) $Checkbox9 = GUICtrlCreateCheckbox("Full Address including suburb, state and postcode", 152, 176, 257, 17) $Checkbox10 = GUICtrlCreateCheckbox("Alt Contact Number", 16, 192, 129, 17) $Checkbox11 = GUICtrlCreateCheckbox("Genuine Interest", 152, 192, 97, 17) $Editbox2 = GUICtrlCreateEdit("", 16, 256, 401, 97, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN)) $Label7 = GUICtrlCreateLabel("Comments", 16, 232, 53, 17) $TabSheet3 = GUICtrlCreateTabItem("Qualifying") $Checkbox12 = GUICtrlCreateCheckbox("Home Owner", 16, 176, 97, 17) $Checkbox13 = GUICtrlCreateCheckbox("Citizen / Residency", 16, 192, 113, 17) $Checkbox14 = GUICtrlCreateCheckbox("No. of Owners", 16, 208, 97, 17) $Checkbox15 = GUICtrlCreateCheckbox("Selling within 12mths", 16, 224, 121, 17) $Checkbox16 = GUICtrlCreateCheckbox("Roof Type", 152, 176, 97, 17) $Checkbox17 = GUICtrlCreateCheckbox("Roof Direction", 152, 192, 97, 17) $Checkbox18 = GUICtrlCreateCheckbox("Roof Size", 152, 208, 97, 17) $Checkbox19 = GUICtrlCreateCheckbox("Shadow", 152, 224, 97, 17) $Checkbox20 = GUICtrlCreateCheckbox("Power Bill Size", 264, 176, 97, 17) $Checkbox21 = GUICtrlCreateCheckbox("Asbestos", 264, 192, 97, 17) $Checkbox22 = GUICtrlCreateCheckbox("All Decision Makers Present", 264, 208, 153, 17) $Editbox3 = GUICtrlCreateEdit("", 16, 272, 401, 81, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN)) $Label8 = GUICtrlCreateLabel("Comments", 16, 248, 53, 17) $TabSheet4 = GUICtrlCreateTabItem("Summary") $Checkbox23 = GUICtrlCreateCheckbox("Booked with Owner", 16, 176, 113, 17) $Checkbox24 = GUICtrlCreateCheckbox("Appointment Booked", 16, 192, 121, 17) $Checkbox25 = GUICtrlCreateCheckbox("Rehash completed at end of call", 192, 176, 169, 17) $Checkbox26 = GUICtrlCreateCheckbox("Company Details given", 192, 192, 129, 17) $Editbox4 = GUICtrlCreateEdit("", 16, 256, 401, 97, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN)) $Label9 = GUICtrlCreateLabel("Comments", 16, 232, 53, 17) GUICtrlCreateTabItem("") $Label10 = GUICtrlCreateLabel("Score:", 8, 368, 49, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Score = GUICtrlCreateLabel("", 64, 368, 28, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Submit", 352, 368, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Clipboard", 272, 368, 75, 25, $WS_GROUP) $Button5 = GUICtrlCreateButton("Clear Data", 192, 368, 75, 25, $WS_GROUP) $Label12 = GUICtrlCreateLabel("BSMART CALL QUALITY SYSTEM ", 40, 0, 354, 34) GUICtrlSetFont(-1, 22, 800, 0, "Kartika") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $Button3 ;copies clients data from BSmart Systems (CRM) into this tool $var2 = ControlGetText("Sale Maintenance", "", "[CLASS:WindowsForms10.COMBOBOX.app.0.33c0d9d; INSTANCE:6]") ControlSetText("BSmart Call Quality","","[CLASS:Edit; INSTANCE:2]",$var2) $var3 = ControlGetText("Sale Maintenance", "", "[CLASS:WindowsForms10.EDIT.app.0.33c0d9d; INSTANCE:12]") ControlSetText("BSmart Call Quality","","[CLASS:Edit; INSTANCE:4]",$var3) Case $msg = $button5 ;clears the following fields GUICtrlSetData($Input3, "") GUICtrlSetData($Input5, "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:1]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:2]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:5]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:6]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:7]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:8]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:9]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:10]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:11]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:12]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:13]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:14]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:15]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:16]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:17]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:18]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:19]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:20]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:21]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:22]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:23]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:24]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:25]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:26]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:27]","UnCheck", "") ControlCommand("BSmart Call Quality", "", "[CLASS:Button; INSTANCE:28]","UnCheck", "") GUICtrlSetData($Editbox1, "") GUICtrlSetData($Editbox2, "") GUICtrlSetData($Editbox3, "") GUICtrlSetData($Editbox4, "") Case $msg = $button4 $var4 = GUICtrlRead($input2) $var10 = guictrlread($Input5) ;msgbox(1,"","Y:\archive\"& Stringright($var4,4) & "-" & stringleft(stringright($var4,7),2)& "\W" & _WeekNumberISO($var4) -2 & "\"& stringleft($var4,2) & "\*" & "0746652227" & ".*") $search = FileFindFirstFile("Y:\archive\"& Stringright($var4,4) & "-" & stringleft(stringright($var4,7),2)& "\W" & _WeekNumberISO($var4) -2 & "\"& stringleft($var4,2) & "\*" & $var10 & "*.*") for $i = 0 to 10 $file = "Y:\archive\"& Stringright($var4,4) & "-" & stringleft(stringright($var4,7),2)& "\W" & _WeekNumberISO($var4) -2 & "\"& stringleft($var4,2) & "\" & FileFindNextFile($search) Local $myarray[10][2] $myarray[$i][0] = "Y:\archive\"& Stringright($var4,4) & "-" & stringleft(stringright($var4,7),2)& "\W" & _WeekNumberISO($var4) -2 & "\"& stringleft($var4,2) & "\" & $file $myarray[$i][1] = FileGetSize($file) If @error Then ExitLoop Next _ArraySort($myarray, 1, 0, 0, 1) _ArrayDisplay($myarray) EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc Edited October 5, 2011 by dajesterofdeath Link to comment Share on other sites More sharing options...
dajesterofdeath Posted July 6, 2011 Author Share Posted July 6, 2011 i resolved my issues i was having. fixed a date issue i found (_weeknumberISO needed more details to give correct week number) and i fixed the array issue, like i said it was my incompetence. i now have it opening the largest file. thanks for all your help guys. Case $msg = $button4 $var4 = GUICtrlRead($input2) $var10 = guictrlread($Input5) ;msgbox(1,"","Y:\archive\"& Stringright($var4,4) & "-" & stringleft(stringright($var4,7),2)& "\W" & _WeekNumberISO(Stringright($var4,4),stringleft(stringright($var4,7),2),stringleft($var4,2)) & "\"& stringleft($var4,2) & "\*" & "0746652227" & ".*") $var12 = "Y:\archive\"& Stringright($var4,4) & "-" & stringleft(stringright($var4,7),2)& "\W" & _WeekNumberISO(Stringright($var4,4),stringleft(stringright($var4,7),2),stringleft($var4,2)) & "\"& stringleft($var4,2) & "\" $search = FileFindFirstFile($var12 & "*" & $var10 & "*.*") Local $myarray[10][2] for $i = 0 to 10 $file = FileFindNextFile($search) If @error Then ExitLoop $myarray[$i][0] = $var12 & $file $myarray[$i][1] = FileGetSize($var12 & $file) Next _ArraySort($myarray, 1, 0, 0, 1) ;_ArrayDisplay($myarray) ShellExecute($myarray[0][0]) 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