After experiencing a lot of down time, We decided to move this site to
CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.
if, and, then Help
|
Author |
Message
|
Renigade
-
Total Posts
:
9
- Scores: 0
-
Reward points
:
0
- Joined: 3/2/2010
-
Status: offline
|
if, and, then Help
Wednesday, March 10, 2010 6:48 AM
( permalink)
I have the following in my code... in dictEvtCodes I have... 0, 2 , 10 in dictEvtType, I have 3, 5 If (NOT dictEvtCodes.Exists(Trim(objEvent.EventCode)) and NOT dictEvtType.Exists(Trim(objEvent.EventType))) Then do something end if When this code runs, everything that has distEvtType is missing and vice versa... I am looking for something that if it is NOT in BOTH Dictionaries then do something... Anyone got an answer for me Please??? Thanks
|
|
|
|
dm_4ever
-
Total Posts
:
3673
- Scores: 82
-
Reward points
:
0
- Joined: 6/29/2006
- Location: Orange County, California
-
Status: offline
|
Re:if, and, then Help
Wednesday, March 10, 2010 6:56 AM
( permalink)
That logic should be working
Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary")
dictEvtCode.Add 0, ""
dictEvtCode.Add 2, ""
dictEvtCode.Add 10, ""
Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary")
dictEvtType.Add 3, ""
dictEvtType.Add 5, ""
If Not dictEvtCode.Exists(4) And Not dictEvtType(234) Then
WScript.Echo "do something"
End If
|
|
|
|
Renigade
-
Total Posts
:
9
- Scores: 0
-
Reward points
:
0
- Joined: 3/2/2010
-
Status: offline
|
Re:if, and, then Help
Wednesday, March 10, 2010 7:06 AM
( permalink)
Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary")
dictEvtCode.Add 0, ""
dictEvtCode.Add 2, ""
dictEvtCode.Add 10, ""
Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary")
dictEvtType.Add 3, ""
dictEvtType.Add 5, ""
If Not dictEvtCode.Exists(4) And Not dictEvtType(234) Then
WScript.Echo "do something"
End If
You would think that it does work... but using above example... If Not dictEvtCode.Exists(2) And Not dictEvtType(4) Then
WScript.Echo "do something"
End If it ends... it will NOT echo the do something as I think it should
|
|
|
|
dm_4ever
-
Total Posts
:
3673
- Scores: 82
-
Reward points
:
0
- Joined: 6/29/2006
- Location: Orange County, California
-
Status: offline
|
Re:if, and, then Help
Wednesday, March 10, 2010 7:09 AM
( permalink)
Weird...it works just fine for me on multiple machines.
|
|
|
|
Renigade
-
Total Posts
:
9
- Scores: 0
-
Reward points
:
0
- Joined: 3/2/2010
-
Status: offline
|
Re:if, and, then Help
Wednesday, March 10, 2010 7:29 AM
( permalink)
Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary")
dictEvtCode.Add 0, ""
dictEvtCode.Add 2, ""
dictEvtCode.Add 10, ""
Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary")
dictEvtType.Add 3, ""
dictEvtType.Add 5, ""
If Not dictEvtCode.Exists(2) And Not dictEvtType(4) Then
WScript.Echo "do something"
End If This should also do something but it does not
|
|
|
|
Deckyon
-
Total Posts
:
45
- Scores: 0
-
Reward points
:
0
- Joined: 8/1/2006
- Location: Louisville, KY - USA
-
Status: offline
|
Re:if, and, then Help
Wednesday, March 10, 2010 7:32 AM
( permalink)
Renigade
Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary")
dictEvtCode.Add 0, ""
dictEvtCode.Add 2, ""
dictEvtCode.Add 10, ""
Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary")
dictEvtType.Add 3, ""
dictEvtType.Add 5, ""
If Not dictEvtCode.Exists(4) And Not dictEvtType(234) Then
WScript.Echo "do something"
End If
You would think that it does work... but using above example... If Not dictEvtCode.Exists(2) And Not dictEvtType(4) Then
WScript.Echo "do something"
End If it ends... it will NOT echo the do something as I think it should In your example above, BOTH statements have to be met before the code will "do something".
|
|
|
|
Deckyon
-
Total Posts
:
45
- Scores: 0
-
Reward points
:
0
- Joined: 8/1/2006
- Location: Louisville, KY - USA
-
Status: offline
|
Re:if, and, then Help
Wednesday, March 10, 2010 7:35 AM
( permalink)
Renigade Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary")
dictEvtCode.Add 0, ""
dictEvtCode.Add 2, ""
dictEvtCode.Add 10, ""
Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary")
dictEvtType.Add 3, ""
dictEvtType.Add 5, ""
If Not dictEvtCode.Exists(2) And Not dictEvtType(4) Then
WScript.Echo "do something"
End If This should also do something but it does not That is because Not dictEvtCode.Exists(2) condition is not met. 2 exists. Both conditions have to be met in order to "do something".
<message edited by Deckyon on Wednesday, March 10, 2010 7:36 AM>
|
|
|
|
Renigade
-
Total Posts
:
9
- Scores: 0
-
Reward points
:
0
- Joined: 3/2/2010
-
Status: offline
|
Re:if, and, then Help
Wednesday, March 10, 2010 8:22 AM
( permalink)
Deckyon Renigade Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary")
dictEvtCode.Add 0, ""
dictEvtCode.Add 2, ""
dictEvtCode.Add 10, ""
Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary")
dictEvtType.Add 3, ""
dictEvtType.Add 5, ""
If Not dictEvtCode.Exists(2) And Not dictEvtType(4) Then
WScript.Echo "do something"
End If This should also do something but it does not That is because Not dictEvtCode.Exists(2) condition is not met. 2 exists. Both conditions have to be met in order to "do something". OK so if I don't want this... I need it to do something if ONLY one or no condition is met... if they BOTH are met I want it to do nothing.
<message edited by Renigade on Wednesday, March 10, 2010 8:37 AM>
|
|
|
|
dm_4ever
-
Total Posts
:
3673
- Scores: 82
-
Reward points
:
0
- Joined: 6/29/2006
- Location: Orange County, California
-
Status: offline
|
Re:if, and, then Help
Wednesday, March 10, 2010 8:36 AM
( permalink)
Change AND to OR then @Deckyon: good catch...I did not see he had changed the values when he re-posted.
<message edited by dm_4ever on Wednesday, March 10, 2010 8:37 AM>
|
|
|
|
Deckyon
-
Total Posts
:
45
- Scores: 0
-
Reward points
:
0
- Joined: 8/1/2006
- Location: Louisville, KY - USA
-
Status: offline
|
Re:if, and, then Help
Wednesday, March 10, 2010 8:40 AM
( permalink)
Then instead of AND, use OR. This assumes that you want the code to do the same thing no matter which condition is met.
|
|
|
|
Renigade
-
Total Posts
:
9
- Scores: 0
-
Reward points
:
0
- Joined: 3/2/2010
-
Status: offline
|
Re:if, and, then Help
Wednesday, March 10, 2010 9:03 AM
( permalink)
Thanks ALL... BIG STUPID here... I just didn't think that the OR would do what I wanted so I didn't try it
|
|
|
|
Online Bookmarks Sharing: