Sign in to follow this  
Followers 0
Bert

Array problem

8 posts in this topic

The following code sometimes works, sometimes doesn't, depending on what PC I run it on. To basically describe what it does, it looks to see what sub folders are in the C:\Documents and Settings folder. I then filter out certain folders I do not want to be shown on a list. Here is the code:

$FileList = _FileListToArray("C:\Documents and Settings\", "*", 2)
_ArrayDisplay($FileList, "") ;used to test to see if I can see what is found. can be commented out
_ArrayDelete($FileList, 0) ;deletes the array item saying how many items are in the array. In my test on my PC, it shows 12
$search_1 = _ArraySearch($FileList, "Admin", 0, 0, 0)
_ArrayDelete($FileList, $search_1)
$search_2 = _ArraySearch($FileList, "Administrator", 0, 0, 0)
_ArrayDelete($FileList, $search_2)
$search_3 = _ArraySearch($FileList, "All Users", 0, 0, 0)
_ArrayDelete($FileList, $search_3)
$search_4 = _ArraySearch($FileList, "default user", 0, 0, 0)
_ArrayDelete($FileList, $search_4)
$search_5 = _ArraySearch($FileList, "LocalService", 0, 0, 0)
_ArrayDelete($FileList, $search_5)
$search_6 = _ArraySearch($FileList, "NetworkService", 0, 0, 0)
_ArrayDelete($FileList, $search_6)
$string_1 = _ArrayToString($FileList, "|")
GUICtrlSetData($Combo_1, $string_1)

What my problem is on a few PCs, I get nothing listed. (Its blank) Anyone got a idea of what I'm doing wrong here?

Share this post


Link to post
Share on other sites



When it does not function, what do you get from:

_ArrayDisplay($FileList, "") ;used to test to see if I can see what is found. can be commented out

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

I put that in jst to see if I'm getting a return on the array to begin with. That always works. I did notice when I remove the filtering, and $string_1 = _ArrayToString($FileList, "|") I always get a return. From what I can tell, the filtering is the problem. But for some reason I do not know what the bug is.

Share this post


Link to post
Share on other sites

Any glaring differences on the systems that have the issue vs. those that don't? I'm thinking OS or SPx differences mostly.


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

My next thought is to replace all the _ArrayDelete lines with _ArrayDisplay to see which line is killing the array

[edit] errr I mean add an _ArrayDisplay after each delete.... you get the idea.

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sorry, mistake- so deleted post

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This probably won't work until you figure out the problem, but here's how I'd go about what you're trying to do in the first place, and not use all those _array functions.

$path = 'c:\documents and settings\'
$first = FileFindFirstFile($path & '*.*')
$filter = 'AdminAdministratorAllUsersdefaultuserLocalServiceNetworkService'
$return = ''

While 1
    $found = FileFindNextFile($first)
    If @error Then ExitLoop
    If StringInStr($filter, StringStripWS($found, 8)) Or _
            Not StringInStr(FileGetAttrib($path & $found), 'D') Then ContinueLoop
    $return &= $found & '|'
WEnd

$return = StringTrimRight($return, 1)

MsgBox(0, '', $return)  ;give this $return to guictrlsetdata()

edit - minor change

Edited by xcal

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