Sign in to follow this  
Followers 0
wisem2540

Designing a filtered array

7 posts in this topic

Hello all,

Looking for a little direction here to get started...

I will return the main array of say...  1000 computers

Then create a GUI with dropdown lists

First dropdown list would be building.

Building1

Building2

Building3

The bulding name would be included in the computer name.  Then I would have a second dropdown with which Floor of the building they were on.  As I select these, I would like to see the list filter down.

So my question is really would I use _ArrayFindAll for this mostly, then loop through and create data for the dropdowns?  Or is there an easier way?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You could create arrays for each building+floor combo.  Then no filter would be needed at all.

Such as in an array of arrays.

#include <Array.au3>
$iBuildingCount = 5
$iFloorCountPerBuilding = 3
$iSomeOtherDataCount = 10

Global Enum $iBuilding, $iFloor, $iOther, $iUbound
Global $aaBuildings[$iBuildingCount*$iFloorCountPerBuilding][$iUbound]

$iCounter = 0
For $j = 0 To $iBuildingCount-1
    For $k = 0 To $iFloorCountPerBuilding-1
        $aaBuildings[$iCounter][$iBuilding]="Building" & $j+1
        $aaBuildings[$iCounter][$iFloor]="Floor" & $k
        Global $otherdata[$iSomeOtherDataCount]
        $aaBuildings[$iCounter][$iOther]=$otherdata
        $iCounter+=1
    Next
Next

_ArrayDisplay($aaBuildings)

[0]|Building1|Floor0|
[1]|Building1|Floor1|
[2]|Building1|Floor2|
[3]|Building2|Floor0|
[4]|Building2|Floor1|
[5]|Building2|Floor2|
[6]|Building3|Floor0|
[7]|Building3|Floor1|
[8]|Building3|Floor2|
[9]|Building4|Floor0|
[10]|Building4|Floor1|
[11]|Building4|Floor2|
[12]|Building5|Floor0|
[13]|Building5|Floor1|
[14]|Building5|Floor2|
 

The 3rd subscript of each record is the array of data.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

That is a fine idea, But I would still have to populate them somehow based on some type of criteria, but you are saying that would be the only "Filter" then correct?

Does it make sense to maintain a large array, or "Array of Arrays?"  Or would I be better off maintaining seperate arrays for each combination?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Performance is supposed to degrade if the array of arrays is too large.  But if you only have 1000, i doubt it will matter.

I threw them all into an array, so it's easier to loop through, and grab data.  If you use multiple arrays, you would still need to have some sort of naming convention to cycle through them, and grab your data. (which is possible, but not as easy as a simple loop).

Global $aBuilding1Floor1[$iSomeOtherDataCount]
Global $aBuilding1Floor2[$iSomeOtherDataCount]
Global $aBuilding2Floor1[$iSomeOtherDataCount]
Global $aBuilding2Floor2[$iSomeOtherDataCount]

$iBuildingCount = 1
While True
    $iFloorCount = 1
    If Not IsArray(Eval("aBuilding" & $iBuildingCount & "Floor" & $iFloorCount)) Then
        ExitLoop
    EndIf
    While True
        If Not IsArray(Eval("aBuilding" & $iBuildingCount & "Floor" & $iFloorCount)) Then
            ExitLoop
        EndIf
        ConsoleWrite("aBuilding" & $iBuildingCount & "Floor" & $iFloorCount & " is valid" & @CRLF)
        $iFloorCount += 1
    WEnd
    $iBuildingcount +=1
WEnd
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

jdelaney,

Thanks for your help.  How would I populate the array? 

Say I had a PC that was named ComputerMain2FLJane

Main is the building

2FL is the floor

Would I just use If StringinStr = 2FL then _ARRAYADD to $FLOOR2?

Edited by wisem2540

Share this post


Link to post
Share on other sites

Where are you getting your data from before it enters the program? Are you going to type the info for all 1,000 computers yourself?

Share this post


Link to post
Share on other sites

SQLite could certainly be put to some use here.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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