Sign in to follow this  
Followers 0
Nomisdk

Array - how to get all rows like..

12 posts in this topic

Hi
 
I have the following code.
 
How do i make, so it only returns the rows with A?
 
#include <Array.au3>
 
Local $aArray[6][2] = [[1, "A"],[2, "B"],[3, "C"],[4, "A"],[5, "B"],[6, "C"]]
_ArrayDisplay($aArray, "2D array") ; Display the current array.
 
 

Share this post


Link to post
Share on other sites



Loop through the array and only select those rows where the  2nd element contains "A".

Easy, right ;)


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

BTW: To post code please use the AutoIt code tag (the blue "A") in the editor.


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

Hi Water

Can you make me a example of how to do it?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Untested.

#include <Array.au3>
 
Local $aArrayIn[6][2] = [[1, "A"],[2, "B"],[3, "C"],[4, "A"],[5, "B"],[6, "C"]]
Local $aArrayOut[6][2]
Local $iIndexOut = 0
For $iIndexIn = 0 to UBound($aArrayIn) - 1
    If $aArrayIn[$iIndexIn][1] = "A" Then
        $aArrayOut[$iIndexOut][0] = $aArrayIn[$iIndexIn][0]
        $aArrayOut[$iIndexOut][1] = $aArrayIn[$iIndexIn][1}
        $iIndexOut = $iIndexOut + 1
    EndIf
Next
ReDim $aArrayOut[$iIndexOut][2]
_ArrayDisplay($aArrayOut, "2D array")
Edited by water

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

Untested.

 

After fixing the typo, works nice  :D

Share this post


Link to post
Share on other sites

Typo, what typo ;)


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

#9 ·  Posted (edited)

$aArrayOut[$iIndexOut][1] = $aArrayIn[$iIndexIn][1} => ]

Edited by Spider001

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Well, thanks Spider001

I was about to reinstall AutoIt, hoping that I would not have to format c:

Edited by mikell
1 person likes this

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Ahhhh, I see :)

Edited by water

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

Well, thanks Spider001

I was about reinstalling AutoIt, hoping that I would not have to format c:

Well i think you need to do a format, this is so strange i think you have a virus or so that change char :sweating:

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