Re: stupid question
- From: "James Whitlow" <jwhitlow.60372693@xxxxxxxxxxxxx>
- Date: Sat, 10 May 2008 13:08:35 -0500
"Al Dunbar" <AlanDrub@xxxxxxxxxxxxxxxxxxx> wrote in message
news:OK9a4HssIHA.2064@xxxxxxxxxxxxxxxxxxxxxxx
What about using a dictionary object to keep a list of the names to
exclude? Something like:
set exclude = createobject("scripting.dictionary")
exclude("database") = true
exclude("images") = true
exclude("etc") = true
' etc, etc, etc
name = "program"
if exclude.exists(name) then
wscript.echo "excluding: " & name
else
wscript.echo "NOT excluding: " & name
end if
The individual elements of the object could alternately be read in from a
file, and/or the whole messy details encapsulated in class or a function.
Interesting tip, Al! Thanks!
I had thought about replying to the thread with a suggestion to consider
the dictionary object, but not in the way you described. I was not aware of
the 'Exclude' method. I went back to 'script56.chm' to see if I missed it
somewhere, and the page for the dictionary object does not list it. It lists
the available methods as Add, Exists, Items, Keys, Remove & RemoveAll. I
tested your code and it works great! I love learning new methods!
Another possible method if reading the list of exclusions from a file
would be to use a regular expression. Assuming each exclusing on an
individual line, something like the code below could be used:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oRegEx = CreateObject("VBScript.RegExp")
sExclusions = oFSO.OpenTextFile("Exclusions.txt", 1).ReadAll
oRegEx.Multiline = True
oRegEx.IgnoreCase = True
sName = "images"
oRegEx.Pattern = "^" & sName & "$"
Select Case oRegEx.Test(sExclusions)
Case True WScript.Echo "Excluding: " & sName
Case False WScript.Echo "NOT Excluding: " & sName
End Select
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.
- Follow-Ups:
- Re: stupid question
- From: Al Dunbar
- Re: stupid question
- References:
- Re: stupid question
- From: Todd Vargo
- Re: stupid question
- From: preet
- Re: stupid question
- From: Joe Fawcett
- Re: stupid question
- From: Todd Vargo
- Re: stupid question
- From: mayayana
- Re: stupid question
- From: Paul Randall
- Re: stupid question
- From: Al Dunbar
- Re: stupid question
- Prev by Date: Re: script to map tcp/ip printer
- Next by Date: Re: Domain connection detection
- Previous by thread: Re: stupid question
- Next by thread: Re: stupid question
- Index(es):
Relevant Pages
|