Jump to content

Arrays, keep on getting extra rows


 Share

Recommended Posts

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)

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

_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

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

Link to comment
Share on other sites

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

 

 

 

Link to comment
Share on other sites

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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