Jump to content
Sign in to follow this  
Nomisdk

Array - how to get all rows like..

Recommended Posts

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

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
water

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
water

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
mikell

Untested.

 

After fixing the typo, works nice  :D

Share this post


Link to post
Share on other sites
water

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
Spider001

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

Edited by Spider001

Share this post


Link to post
Share on other sites
mikell

Well, thanks Spider001

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

Edited by mikell
  • Like 1

Share this post


Link to post
Share on other sites
water

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
Spider001

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.