deef99 Posted December 14, 2010 Share Posted December 14, 2010 Hello Again,Thanks to this forum, I've gotten much farther on my code, but I seem to be doing something wrong in the searching of the array now. I know that Column 18 contains the words Heat xx [ex. Heat 23], but it doesn't find it... what am I doing wrong please?Heatlist.txt:M;P;Denny;Lennon;;;15;F;A;Ann;Allen;;;4294967295;Chattanooga Dancesport;1;12/03/2010 20:00;Heat 1;American Smooth Single Dance Events;Waltz;Full Silver;B2;2;M;P;Leon;Selby;;;31;F;A;Diane;Stockton;;;4294967295;Dancemakers;1;12/03/2010 20:00;Heat 1;American Smooth Single Dance Events;Waltz;Full Silver;B2;1;M;P;Joe;LoCurto;;;35;F;A;Marion;Helman;;;4294967295;Academy Ballroom Atlanta;1;12/03/2010 20:00;Heat 3;American Smooth Single Dance Events;Waltz;Full Silver;B2;3;M;P;Jorge;Morales;;;36;F;A;Antoinette;Fernando;;;4294967295;Academy Ballroom Atlanta;1;12/03/2010 20:00;Heat 5;American Smooth Single Dance Events;Waltz;Full Silver;B2;4;M;P;David;Wood;;;32;F;A;Mary Gordon;Taft;;;4294967295;Dancemakers;1;12/03/2010 20:01;Heat 9;American Smooth Single Dance Events;Tango;Preliminary Silver;C2;1;-------------------------------------------------------------------------------#include <Array.au3>; Start array on element 1 of the 2nd dimension$a_array_one = _MyCSVCustomFunc("C:\cmpmgr\heatlist.txt");_ArrayDisplay($a_array_one); Start array on element 0 of the 2nd dimension$a_array_two = _MyCSVCustomFunc("C:\cmpmgr\heatlist.txt");_ArrayDisplay($a_array_two, "", 0)Func _MyCSVCustomFunc($s_csv_file, $s_delimiter = ";", $i_base = 1) Local $s_read = FileRead($s_csv_file) Local $a_split_lines = StringSplit(StringStripCR($s_read), @LF) ; Create 2D array Local $a_ret[$a_split_lines[0] + 1][1] Local $a_split, $i_add = 0, $i_last_ub = 1 ; Populate 2D array For $i = 1 To $a_split_lines[0] If $a_split_lines[$i] Then $i_add += 1 $a_split = StringSplit($a_split_lines[$i], $s_delimiter) If $i_last_ub < $a_split[0] Then $i_last_ub = $a_split[0] Redim $a_ret[$a_split_lines[0] + 1][$a_split[0] + 1] EndIf For $n = 1 To $a_split[0] $a_ret[$i_add][($n - 1) + $i_base] = $a_split[$n] Next EndIf Next ; If there are no matches, set error and return If $i_add = 0 Then Return SetError(1, 0, 0) ; Reset array with correct dimensions (we only want data, not blank lines) ReDim $a_ret[$i_add + 1][$i_last_ub + 1] $a_ret[0][0] = $i_add Return $a_retEndFunc**** PROBLEM IS DOWN HERE SOMEWHERE ****global $a_array_two, $iIndex_ArrayDisplay($a_array_two, "", 0)$sSearch = InputBox($a_array_two, "Row Number?")If @error Then Exit$sColumn = InputBox($a_array_two, "Column to search?")If @error Then Exit$sColumn = Int($sColumn)$iIndex = _ArraySearch($a_array_two, $sSearch, 0, 0, 0, 1, $sColumn)If @error Then MsgBox(0, "Not Found", '"' & $sSearch & '" was not found on column ' & $sColumn & '.')Else MsgBox(0, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & ' on column ' & $sColumn & '.')EndIf Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2010 Moderators Share Posted December 14, 2010 deef99,It might help if you had the correct syntax for the _ArraySearch function - and if you actually asked the function to search for something! At the moment you are using the Row number as the value to search for - so you are very unlikely to find "Heat" or any other string. Furthermore you have missed out the $iForward parameter in the _ArraySearch call, so you are not searching the column you think you are.Take a look at this slightly modified script - I get the correct answers when I try it: #include <Array.au3> ; Start array on element 1 of the 2nd dimension $a_array_one = _MyCSVCustomFunc("C:\cmpmgr\heatlist.txt") ;_ArrayDisplay($a_array_one) ; Start array on element 0 of the 2nd dimension $a_array_two = _MyCSVCustomFunc("C:\cmpmgr\heatlist.txt") ;_ArrayDisplay($a_array_two, "", 0) Global $a_array_two, $iIndex _ArrayDisplay($a_array_two, "", 0) $sSearch = InputBox($a_array_two, "Text to find") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If @error Then Exit $sColumn = InputBox($a_array_two, "Column to search?") If @error Then Exit $sColumn = Int($sColumn) $iIndex = _ArraySearch($a_array_two, $sSearch, 0, 0, 0, 1, 1, $sColumn) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If @error Then MsgBox(0, "Not Found", '"' & $sSearch & '" was not found on column ' & $sColumn & '.') Else MsgBox(0, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & ' on column ' & $sColumn & '.') EndIfAll clear? M23P.S. When you post code please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
deef99 Posted December 14, 2010 Author Share Posted December 14, 2010 AWESOME!!!!!! Thanks for the super quick response! One more question please if I may... Now that I can find the record containing the information, I will want to get the 3 columns after Column 18, and will be saving that data to create a printout on the fly. Can you point me in the direction of what commands I should be looking at to do this? Appreciate it very much! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2010 Moderators Share Posted December 14, 2010 deef99, The search will give you the value of the first dimension of the array which holds the required text - and you say that you wish to extract the data in columns 19-21. Thus a small loop should do what you want: $iIndex = _ArraySearch($a_array_two, $sSearch, 0, 0, 0, 1, 1, $sColumn) If @error Then MsgBox(0, "Not Found", '"' & $sSearch & '" was not found on column ' & $sColumn & '.') Else MsgBox(0, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & ' on column ' & $sColumn & '.') EndIf ; Create an empty string $sData = "" For $i = 19 To 21 ; Add the data to the string $sData &= $a_array_two[$iIndex][$i] & @CRLF Next ; And display it MsgBox(0, "Data", $sData) I hope that helps. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
deef99 Posted December 14, 2010 Author Share Posted December 14, 2010 Perfect!!!! Ok I am moving on....thanks again for the great help! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2010 Moderators Share Posted December 14, 2010 deef99, Glad I could help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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