Jump to content

Recommended Posts

Posted

Every-time I do "_ArrayPush()" or "_ArrayUnique" I'm keep on getting extra values in my Arrays @ position [0]. It seems to be a count of all the values in my Arrays. Is there a way to disable it? It is really frustrating. I'm keep on using _ArrayDelete($OArray,0)

Posted (edited)

Help File for _ArrayUnique

  Quote

$iCount [optional] Flag to determine if [0] element holds the count of returned items (default) - see Remarks for details. 

Expand  

 

Edited by iamtheky

  Reveal hidden contents

Posted

As I stated in your other array-related thread: The help file is your friend!

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Thank you so much for your reply, now I'm on a right path

However, I'm such a noob. Do I modify $iCount in "Array.au3" file or do I declare my arrays in a certain way, may be something like this?

_ArrayUnique($NArray, $iDimension = 1, $iBase = 0, $iCase = 0, $vDelim = "|")
_ArrayUnique($OArray, $iDimension = 1, $iBase = 0, $iCase = 0, $vDelim = "|")

I'm working on a script that adds Text from a *.txt file to a ListBox (I want new bits of text to go on top of my listbox). However, those arrays are killing me.

my scrip is like this:

Func Load()
    If $OArray[0] = "" Then
        $sFile = "symbols.txt"; open file for reading
        _FileReadToArray($sFile, $OArray)
        _ArrayDelete($OArray, 0)

        $OArray = _ArrayUnique($OArray)
        _ArrayDelete($OArray,0)

        For $i = 0 to UBound($OArray) - 1
            GUICtrlSetData($List1, $OArray[$i])
        Next
    EndIf



    IF $OArray[0] <> "" Then
        $sFile = "symbols.txt"; open file for reading
        _FileReadToArray($sFile, $NArray)
        _ArrayDelete($NArray, 0)

        $NArray = _ArrayUnique($NArray)
        _ArrayDelete($NArray,0)

        For $a = UBound($NArray) -1 To 0 Step -1
            For $b = 0 To UBound($OArray) - 1
                If $NArray[$a] = $OArray[$b] Then
                    _ArrayDelete($NArray, $a)
                    ExitLoop
                EndIf
            Next
        Next

        ;_ArrayDisplay($NArray)
        if IsArray($NArray) Then
            If $NArray[0] <> "" Then
                _ArrayPush($OArray,$NArray,1)   ;STOP THIS SHIT
                _GUICtrlListBox_ResetContent ( $List1 )
                For $i = 0 to UBound($OArray) - 1
                    GUICtrlSetData($List1, $OArray[$i])
                Next
                $NArray  = 0
                For $b = 0 To UBound($NArray) - 1
                        _ArrayDelete($NArray, $b)
                        ExitLoop
                Next
            EndIf
            $NArray = $aEmpty

        EndIf
    EndIf
EndFunc

 

 

Posted (edited)
_ArrayUnique ( Const ByRef $aArray [, $iColumn = 0 [, $iBase = 0 [, $iCase = 0 [, $iCount = $ARRAYUNIQUE_COUNT [, $iIntType = $ARRAYUNIQUE_AUTO]]]]] )

see how the first parameter doesnt have an equal sign, that one is required, that is the array you specify.

the others are preset for all intents and purposes so you are really sending _ArrayUnique($aArray, 0, 0, 0, $ARRAYUNIQUE_COUNT , $ARRAYUNIQUE_AUTO)

you want $ARRAYUNIQUE_NOCOUNT.

 

Edited by iamtheky

  Reveal hidden contents

Posted
  On 8/28/2017 at 5:19 AM, toto22 said:

I can't get this to work. I'm getting all kind of errors.

 

---------------------------
AutoIt Error
---------------------------
Line 42  (File "C:\Users\toto\Desktop\Autoit\TC2000\GUI\0004 - GUI.au3"):

_ArrayUnique($aArray, 0, 0, 0, $ARRAYUNIQUE_NOCOUNT , $ARRAYUNIQUE_AUTO)
_ArrayUnique($aArray, 0, 0, 0, ^ ERROR

Error: Variable used without being declared.
---------------------------
OK   
---------------------------

 

 

Expand  

 

Posted

That shows us that it is always quite helpful to add the used AutoIt version to a new thread ;)

My UDFs and Tutorials:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...