toto22

Arrays, keep on getting extra rows

8 posts in this topic

#1 ·  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)

Share this post


Link to post
Share on other sites



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

 

Edited by iamtheky
1 person likes this

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#3 ·  Posted

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

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  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

 

 

Share this post


Link to post
Share on other sites

#5 ·  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
1 person likes this

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#6 ·  Posted

16 minutes ago, 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   
---------------------------

 

 

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

oh I just needed a new version of autoit

Share this post


Link to post
Share on other sites

#8 ·  Posted

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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