Re: stupid question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"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
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


.



Relevant Pages

  • Re: stupid question
    ... set exclude = createobject ... The individual elements of the object could alternately be read in from a ... and the page for the dictionary object does not ... It lists the available methods as Add, Exists, Items, Keys, ...
    (microsoft.public.scripting.vbscript)
  • Re: Anti-Virus File/Directories Exclusions
    ... Gregg Hill ... which should grab your exclusions as well. ... time instead of just pasting a list of folders into the console. ... Files to exclude from Trend ...
    (microsoft.public.windows.server.sbs)
  • Re: Anti-Virus File/Directories Exclusions
    ... which should grab your exclusions as well. ... had a need to import them back into the Trend databases yet, ... In Trend, one can add them, but you have to do so one folder at a time ... Files to exclude from Trend ...
    (microsoft.public.windows.server.sbs)
  • Re: Combo box question
    ... I wanted to exclude the last entry in the table purely on the ... basis that that scheme was not yet in use, therefore I did not want the name ... of the scheme to appear in any combo boxes that lists that particular set of ... the various exclusion methods that you highlight for other database tables, ...
    (microsoft.public.vb.syntax)
  • Re: yum - prevent Redhat-Release update
    ... it has an exclude list you can add to the configuration file. ... I've looked at using the security plugin option, but I want to keep getting ... can I simply add exclude or skip lists in the yum ...
    (RedHat)