Sign in to follow this  
Followers 0
hoang92bn

Array variable has incorrect number ........

22 posts in this topic

#1 ·  Posted (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

 

script:

#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 by hoang92bn

Share this post


Link to post
Share on other sites



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]? :huh:

If so, I would do it like this:

#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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (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]? :huh:

If so, I would do it like this:

#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:

 
or:

 

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 by hoang92bn

Share this post


Link to post
Share on other sites

hoang92bn,

That is no help at all! :wacko:

Which do you want? An array of the same blog ID numbers or an array with unique blog ID numbers? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

StringSplit or _FileReadToArray?


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#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.

1 person likes this

Share this post


Link to post
Share on other sites

hoang92bn,

I still have no real idea what you are after, but this produces the array you say you want:

#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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (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:

 
Edited by hoang92bn

Share this post


Link to post
Share on other sites

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? :huh:

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. :huh2:

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

i need return an array contain links which domain name of links is unique. NOT an array content unique domain :(

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

 

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

Share this post


Link to post
Share on other sites

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:

#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

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks, thanks u vey much  :D. ah, can u explant why my script #1 appear error?

Share this post


Link to post
Share on other sites

hoang92bn,
 
Hurrah - we finally got there!!! :party:
 
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

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

yep, i see :)

but, can u have solution? i give up ^^

it seem 

 

$total -= 1

 have no effect?

Edited by hoang92bn

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0