stressmathers
-
Total Posts
:
3
- Scores: 0
-
Reward points
:
0
- Joined: 2/3/2012
-
Status: offline
|
My first question
Friday, February 03, 2012 10:46 PM
( permalink)
I'm trying to do the legwork and avoid asking questions. Personally I learn a lot more by figuring things out but this one is stumping me. Keep in mind I'm just starting out so I'm experimenting - I know you would never actually write a script this way. Anyway, can anyone tell me why I get a different response with the second part of the script than the first? I added the first part to simplify things but when it gave me the appropriate response I was baffled. Oh, I did this on a Saturday so the Weekday(now)) value is 7 (I added the .echo just to be sure!). Sorry about the formatting, but I'm not going to ask. I know you guys are probably sick of hearing about it. x = 10
If x = 1 or 3 or 4 or 5 or 6 or 7 or 8 or 9 then
wscript.echo "I'm not ten"
else wscript.echo "I'm 10"end if
wscript.echo weekday(now())
If weekday(now()) = 2 or 3 or 4 or 5 or 6 then wscript.echo "It's the weekday"
else wscript.echo "It's the weekend"end if
|
|
|
|
Wakawaka
-
Total Posts
:
456
- Scores: 23
-
Reward points
:
0
- Joined: 8/27/2009
-
Status: offline
|
Re:My first question
Saturday, February 04, 2012 12:59 AM
( permalink)
Your second test it turning out like that because you are using the Or operation improperly. How you are using it is actually the bitwise operation so it is Or'ing there bit values, which in this case the values = 7 (which would mean it would print out "It's a weekday"). What you want to use is the logical operator or you can use a select case, which is much easier to use in this case.
Select Case Weekday(Now())
Case 2, 3, 4, 5, 6
WScript.Echo "It's a weekday"
Case Else
WScript.Echo "It's a weekend"
End Select If this helps, when you use the bitwise Or it will compare their bit values and it there is a "On" bit it will be "On" in the result. 2 = 010 3 = 011 4 = 100 5 = 101 6 = 110 -------------- Result = 111 (7 in decimal)
<message edited by Wakawaka on Saturday, February 04, 2012 1:08 AM>
|
|
|
|
stressmathers
-
Total Posts
:
3
- Scores: 0
-
Reward points
:
0
- Joined: 2/3/2012
-
Status: offline
|
Re:My first question
Monday, February 13, 2012 1:56 AM
( permalink)
Yikes. Thanks, because I never would have figured that one out.
|
|
|
|