Sign in to follow this  
Followers 0
Donovan6

Array Entry search with other Array Entries

3 posts in this topic

Hey guys,

I'm working on a bit of filtering code, but I can't seem to snap the logic behind what i want to do and code it, i've thought about it so much now that my mind is just numb so i figured i'd ask for some help.

This code i post is what i have so far, please note, the $Datapath = "\Windows\" should basically be code that uses the $DataPathsArray entries to search the FixedDRVArray entries (each one with all the entries in $DatapathsArray) and add all matches (the combination of the drive letter and path, if a match is found on a drive) to the $MatchesArray.

Heres my code if someone could show me an example i'd be much appreciative.

-----------------------------------------

#include <array.au3>

#include <file.au3>

_FixedDrvArray()

Func _FixedDrvArray()

Global $FixedDrvArray = DriveGetDrive("FIXED")

_ArrayDelete($FixedDrvArray, 0)

EndFunc

_ArrayDisplay($FixedDRVArray)

Global $DataPathsArray[2]

$DataPathsArray[0] = "\Windows\"

$DataPathsArray[1] = "\My Docs\"

Global $MatchesArray[1]

$MatchesArray[0] = "Zeroth"

_VerifyDataPath()

Func _VerifyDataPath()

While UBound($FixedDRVArray)

$PathTrue = ""

$DRVCycle = _ArrayPop($FixedDRVArray)

$DataPath = "\windows\"

$PathTrue = FileExists($DRVCycle & $DataPath)

If $PathTrue = 1 Then

_ArrayAdd($MatchesArray, $DRVCycle & $DataPath)

EndIf

WEnd

EndFunc

_ArrayDelete($MatchesArray, 0)

_ArrayDisplay($MatchesArray)

Share this post


Link to post
Share on other sites



Hmmmm, nobody wants to give it a crack?

Maybie my code wotn work for people as it searches drives for paths which might not work on other peoples configurations.

Scrap my code, basically all i want to do is this...

DRIVEarray

C:

D:

E:

etc...

each entry is then matched to form a string with an entry of...

PATHarray

\windows\

\Favourites\

\My Documents\

etc...

so starting with DRIVEarray entry 1 which = C:

My code (already does this) will make a string of "C:" and entru one of PATHarray, which = \Windows\

So this is the search string...

C:\Windows\

but it must do this for D:, E:, F: etc. as many entries as there are, and once done, it must take that whole DRIVEarray and start again with entry 2 in PATHarray, which now will = \Favourites\

and so it must go on...

Once a match is found it will write the path that has a match to MATHESarray... this i've coded and its working,

What i cant get done myself is to search each entry of DRIVEarray with every entry of PATHarray one at a time and continue adding matches as found till DRIVEarray had all its entries searched with all the entries of PATHarray.

I'll be coding a bit more on it today, but if anyone wants to whack at it, i'd be greatful.

Share this post


Link to post
Share on other sites

Ok, I got it coded...

Amazingly pen and paper worked quite well to get the logic i needed to code it.

I just have one question now, since my method depletes all entries in an Array and leaves it empty once used (more efficient as it wont use memory then), i would like to not have to repopulate depleted Arrays before the function completes.

Is there a way to do this with arrays...

$Original = "12345"

$Copy = $Original

this means if i change or delete $Copy, $Original is unaffected and i can call on it to redefine what $Copy must be.

I've tried doing this with arrays, but it can't.

How do i basically, CLONE an array, deplete that and simply have it = the original Array again to basically repopulate it?

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