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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Nomisdk

Hi Water

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

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
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  

×