hoang92bn Posted May 25, 2013 Share Posted May 25, 2013 (edited) I dont understand what making error: E:SetupAutoittest.au3 (30) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: Plz fix for me List.txt http://crusader.com/blog.php?id=7 http://crusader.com/blog.php?id=6 http://crusader.com/blog.php?id=44 http://crusader.com/blog.php?id=232 http://crusader.com/blog.php?id=2 http://crusader.net/blog.php?id=7 http://crusader.net/blog.php?id=6 http://crusader.org/blog.php?id=7 http://crusader.org/blog.php?id=33 http://crusader.org/blog.php?id=43 script: expandcollapse popup#include <Array.au3> Func readfile($fname) Local $file = FileOpen($fname, 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open " & $fname) Exit EndIf Local $data = "" While 1 Local $chars = FileRead($file, 1) If @error = -1 Then ExitLoop $data &= $chars WEnd Return $data EndFunc Func getDomain($url) Local $urlArr = StringSplit($url,"/",2) If UBound($urlArr) >=2 Then Local $domain = $urlArr[2] return $domain EndIf EndFunc Func filterDomain($arr) Local $total = UBound($arr) For $i = $total - 1 To 0 Step -1 $domain = getDomain($arr[$i]) ; Error here .............. For $j = $i - 1 To 0 Step -1 if $domain == getDomain($arr[$j]) Then _ArrayDelete($arr,$j) _ArraySort($arr) $total -= 1 $j -= 1 EndIf Next Next Return $arr EndFunc $tempListArr = StringSplit(readfile("List.txt"),@CR) _ArrayDelete($tempListArr,0) ;_ArrayDisplay($tempListArr) $arrSite = filterDomain($tempListArr) _ArrayDisplay($arrSite) Edited May 25, 2013 by hoang92bn Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 25, 2013 Moderators Share Posted May 25, 2013 hoang92bn, Welcome to the AutoIt forum. I am rather confused by what you are trying to do - are you expecting a final array which just has 3 elements: [crusader.com] [crusader.net][crusader.org]? If so, I would do it like this: expandcollapse popup#include <Array.au3> $tempListArr = StringSplit(readfile("List.txt"), @CRLF, 1) _ArrayDelete($tempListArr, 0) _ArrayDisplay($tempListArr, "As read") $arrSite = filterDomain($tempListArr) _ArrayDisplay($arrSite, "Unique") Func readfile($fname) Local $file = FileOpen($fname) If $file = -1 Then MsgBox(0, "Error", "Unable to open " & $fname) Exit EndIf Local $data = FileRead($file) ; Just read it all in one go <<<<<<<<<<<<<<<<<<<<< FileClose($file) ; Important <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Return $data EndFunc ;==>readfile Func filterDomain($arr) ; Loop through the array For $i = 0 To UBound($arr) - 1 ; Extract the URL and replace the current value Local $urlArr = StringSplit($arr[$i], "/") ; Use the count in the [0] element If $urlArr[0] >= 2 Then $arr[$i] = $urlArr[3] ; Replace the current element EndIf Next _ArrayDisplay($arr, "When Split") ; Get unique values Local $UniueArray = _ArrayUnique($arr) _ArrayDelete($UniueArray, 0) Return $UniueArray EndFunc ;==>filterDomain 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...
hoang92bn Posted May 25, 2013 Author Share Posted May 25, 2013 thanks, but i want to extract final result with full link, such as: http://crusader.com/blog.php?id=7 http://crusader.net/blog.php?id=7 http://crusader.org/blog.php?id=7 or: http://crusader.com/blog.php?id=2 http://crusader.net/blog.php?id=6 http://crusader.org/blog.php?id=43 Link to comment Share on other sites More sharing options...
hoang92bn Posted May 25, 2013 Author Share Posted May 25, 2013 (edited) hoang92bn, Welcome to the AutoIt forum. I am rather confused by what you are trying to do - are you expecting a final array which just has 3 elements: [crusader.com] [crusader.net][crusader.org]? If so, I would do it like this: expandcollapse popup#include <Array.au3> $tempListArr = StringSplit(readfile("List.txt"), @CRLF, 1) _ArrayDelete($tempListArr, 0) _ArrayDisplay($tempListArr, "As read") $arrSite = filterDomain($tempListArr) _ArrayDisplay($arrSite, "Unique") Func readfile($fname) Local $file = FileOpen($fname) If $file = -1 Then MsgBox(0, "Error", "Unable to open " & $fname) Exit EndIf Local $data = FileRead($file) ; Just read it all in one go <<<<<<<<<<<<<<<<<<<<< FileClose($file) ; Important <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Return $data EndFunc ;==>readfile Func filterDomain($arr) ; Loop through the array For $i = 0 To UBound($arr) - 1 ; Extract the URL and replace the current value Local $urlArr = StringSplit($arr[$i], "/") ; Use the count in the [0] element If $urlArr[0] >= 2 Then $arr[$i] = $urlArr[3] ; Replace the current element EndIf Next _ArrayDisplay($arr, "When Split") ; Get unique values Local $UniueArray = _ArrayUnique($arr) _ArrayDelete($UniueArray, 0) Return $UniueArray EndFunc ;==>filterDomain I hope that helps. M23 thanks, but i want to extract final result with full link, such as: http://crusader.com/blog.php?id=7 http://crusader.net/blog.php?id=7 http://crusader.org/blog.php?id=7 or: http://crusader.com/blog.php?id=2 http://crusader.net/blog.php?id=6 http://crusader.org/blog.php?id=43 I try this func: Func filterDomain2($arr) If IsArray($arr) Then $total = UBound($arr) For $i = 0 to UBound($arr) - 1 $domain = getDomain($arr[$i]) For $j = $i + 1 To $total - 1 If $domain == getDomain($arr[$j]) Then ; error @@ _ArrayDelete($arr,$j) $total -= 1 $j -= 1 EndIf Next Next EndIf return $arr EndFunc but appear same error @@ Edited May 25, 2013 by hoang92bn Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 25, 2013 Moderators Share Posted May 25, 2013 hoang92bn,That is no help at all! Which do you want? An array of the same blog ID numbers or an array with unique blog ID numbers? 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...
hoang92bn Posted May 26, 2013 Author Share Posted May 26, 2013 hoang92bn, That is no help at all! Which do you want? An array of the same blog ID numbers or an array with unique blog ID numbers? M23 i want an array full URL with unique domain. a array just has 3 elements bellow: http://crusader.com/blog.php?id=7 http://crusader.net/blog.php?id=7 http://crusader.org/blog.php?id=7 Link to comment Share on other sites More sharing options...
guinness Posted May 26, 2013 Share Posted May 26, 2013 StringSplit or _FileReadToArray? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
nAutoIT Posted May 26, 2013 Share Posted May 26, 2013 #include <array.au3> Global $url_array[1] Global $domain_array[1] $file = FileOpen("List.txt", 0) While True $line = FileReadLine($file) If @error = -1 Then ExitLoop $split_array = StringSplit($line, "/") If _ArraySearch($domain_array, $split_array[3]) = -1 Then _ArrayAdd($url_array, $line) _ArrayAdd($domain_array, $split_array[3]) EndIf WEnd _ArrayDelete($url_array, 0) _ArrayDisplay($url_array) This should do it quick and dirty, if i understand you correctly. hoang92bn 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 26, 2013 Moderators Share Posted May 26, 2013 hoang92bn, I still have no real idea what you are after, but this produces the array you say you want: expandcollapse popup#include <Array.au3> $sFileName = "List.txt" $sData = readfile($sFileName) $aLines = StringSplit($sData, @CRLF, 1) _ArrayDelete($aLines, 0) _ArrayDisplay($aLines, "As read") ; Just for display <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $aSites = filterDomain($aLines, $sData) If IsArray($aSites) Then _ArrayDisplay($aSites, "Sites") Else MsgBox(0, "Error", "No all domain ID found") EndIf Func readfile($sFileName) Local $sData = FileRead($sFileName) If @error Then MsgBox(0, "Error", "Unable to open " & $sFileName) Exit Return $sData EndIf Return $sData EndFunc ;==>readfile Func filterDomain($aURLs_Read, $sData_Read) Local $aRet = "" ; Get array of ID values $aID = StringRegExp($sData_Read, "(?i)id=(\d+)", 3) _ArrayDisplay($aID, "IDs") ; Just for display <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Now search for a value with 3 instances For $i = 0 To UBound($aID) - 1 ; Search the array for other instances of this ID value $aInstances = _ArrayFindAll($aID, $aID[$i]) _ArrayDisplay($aInstances, $aID[$i]) ; Just for display <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; If 3 instances found If UBound($aInstances) = 3 Then ; Create an array and fill with corresponding URLs Local $aRet[3] For $j = 0 To 2 $aRet[$j] = $aURLs_Read[$aInstances[$j]] Next ; No point in looking further ExitLoop EndIf Next ; Return the array or an empty string if not found Return $aRet EndFunc ;==>filterDomain I hope that is what you wanted. 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...
hoang92bn Posted May 26, 2013 Author Share Posted May 26, 2013 (edited) #include <array.au3> Global $url_array[1] Global $domain_array[1] $file = FileOpen("List.txt", 0) While True $line = FileReadLine($file) If @error = -1 Then ExitLoop $split_array = StringSplit($line, "/") If _ArraySearch($domain_array, $split_array[3]) = -1 Then _ArrayAdd($url_array, $line) _ArrayAdd($domain_array, $split_array[3]) EndIf WEnd _ArrayDelete($url_array, 0) _ArrayDisplay($url_array) This should do it quick and dirty, if i understand you correctly. yes, but i need a function to process an array M23 this script return what i want, but it dont work with other lists: http://crusader.com/new.php?newid=7 http://crusader.com/blog.php?id=6 http://crusader.com/blog.php?item=44 Edited May 26, 2013 by hoang92bn Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 26, 2013 Moderators Share Posted May 26, 2013 hoang92bn, Please stop quoting the replies you receive - we know what we posted. You are not getting what you want because you are not explaining clearly what you want. You keep posting short lists which you say you want returned, but these seem to have no logical pattern relative to the list of URLs you posted initially. Please explain what parameters determine whether an item in the main list should be returned - exactly what elements of the line make it special? To my eyes there seem to be 2 differences between the various lines: the suffix (com, org, net) and the blog ID. So what about these 2 elements determines whether the line should be returned? We can only help you if you explain clearly what it is we need to do - so over to you. 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...
hoang92bn Posted May 26, 2013 Author Share Posted May 26, 2013 can u fix my srcipt on post #1? ( ) or write for me a function to proccess an array. This function will filter domain, it only filters based on domain names, not based on any parameter determine, return an array contain links which domain name is unique. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 26, 2013 Moderators Share Posted May 26, 2013 hoang92bn, I am sorry, but that is not clear at all. it only filters based on domain names That is what I gave you in the script in post #2 above - and you said that was not what you wanted. What I suggest you do is post one of these lists and mark next to it which elements should be returned and why - something like this (I know it is not what you want, but it gives you the idea): http://crusader.com/blog.php?id=7 ; Return because each domain has this ID http://crusader.com/blog.php?id=6 http://crusader.com/blog.php?id=44 http://crusader.com/blog.php?id=232 http://crusader.com/blog.php?id=2 http://crusader.net/blog.php?id=7 ; Return because each domain has this ID http://crusader.net/blog.php?id=6 http://crusader.org/blog.php?id=7 ; Return because each domain has this ID http://crusader.org/blog.php?id=33 http://crusader.org/blog.php?id=43 Then we can see what we have to detect and return. 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...
hoang92bn Posted May 26, 2013 Author Share Posted May 26, 2013 i need return an array contain links which domain name of links is unique. NOT an array content unique domain Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 26, 2013 Moderators Share Posted May 26, 2013 hoang92bn, Last chance - post a list as I suggested showing which elements of your list should be returned or I am out of here. 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...
hoang92bn Posted May 26, 2013 Author Share Posted May 26, 2013 http://crusader.com/blog.php?id=7 | Domain crusader.com http://crusader.com/blog.php?id=6 | Domain crusader.com http://crusader.com/blog.php?id=44 | Domain crusader.com http://crusader.com/blog.php?id=232 | Domain crusader.com -> return one of them http://crusader.net/blog.php?id=7 | Domain crusader.net http://crusader.net/blog.php?id=6 | Domain crusader.net -> return one of them http://crusader.org/blog.php?id=7 | Domain crusader.org http://crusader.org/blog.php?id=33 | Domain crusader.org http://crusader.org/blog.php?id=43 | Domain crusader.org -> return one of them Similar to the other links, other domains........ i need get 3 element. Do u understand :-s Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted May 26, 2013 Moderators Solution Share Posted May 26, 2013 hoang92bn, What about this - it gets the unique domain names from the list and then returns 1 URL from the list for each of them: expandcollapse popup#include <Array.au3> $tempListArr = StringSplit(readfile("List.txt"), @CRLF, 1) _ArrayDelete($tempListArr, 0) $arrSite = filterDomain($tempListArr) _ArrayDisplay($arrSite) Func readfile($fname) Local $data = FileRead($fname) ; Just read it all in one go <<<<<<<<<<<<<<<<<<<<< If @error Then MsgBox(0, "Error", "Unable to open " & $fname) Exit EndIf Return $data EndFunc ;==>readfile Func filterDomain($arr) ; Create an array to hold the domains Local $aDomain[UBound($arr)] ; Loop through the array For $i = 0 To UBound($arr) - 1 ; Extract the domain Local $urlArr = StringSplit($arr[$i], "/") ; Use the count in the [0] element If $urlArr[0] >= 2 Then $aDomain[$i] = $urlArr[3] ; Store the domain EndIf Next ; Get unique domains Local $UniqueArray = _ArrayUnique($aDomain) _ArrayDelete($UniqueArray, 0) ; Now find the first match for each domain For $i = 0 To UBound($UniqueArray) - 1 ; Look for a match $iIndex = _ArraySearch($arr, $UniqueArray[$i], 0, 0, 0, 1) If $iIndex <> -1 Then ; And put it into the array $UniqueArray[$i] = $arr[$iIndex] EndIf Next Return $UniqueArray EndFunc ;==>filterDomain I hope this is finally what you are looking for. M23 hoang92bn 1 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...
hoang92bn Posted May 26, 2013 Author Share Posted May 26, 2013 Thanks, thanks u vey much . ah, can u explant why my script #1 appear error? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 26, 2013 Moderators Share Posted May 26, 2013 hoang92bn, Hurrah - we finally got there!!! Now I understand what you were trying to do I can explain why the first script failed. You were deleting elements from the array but not reducing the loop value you were using to access it. When I run this code: Func filterDomain($arr) Local $total = UBound($arr) For $i = $total - 1 To 0 Step -1 ConsoleWrite("Look at element:" & $i & @CRLF) $domain = getDomain($arr[$i]) ; Error here .............. For $j = $i - 1 To 0 Step -1 if $domain == getDomain($arr[$j]) Then _ArrayDelete($arr,$j) ConsoleWrite("Deleted element: " & $j & @CRLF) _ArraySort($arr) $total -= 1 $j -= 1 EndIf Next Next Return $arr EndFunc on the list I get the following: Look at element: 9 ; Array has 9 elements Delete element: 8 ; Array has 8 elements Delete element: 6 ; Array has 7 elements Look at element: 8 ; Oops there is no element 8 any more All clear? M23 hoang92bn 1 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...
hoang92bn Posted May 26, 2013 Author Share Posted May 26, 2013 (edited) yep, i see but, can u have solution? i give up ^^ it seem $total -= 1 have no effect? Edited May 26, 2013 by hoang92bn 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