My first question

Author Message
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)
0
[Helpful answer received] / [List Solutions Only]
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 

 
 
 
 
I'm trying
 
#1
    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)
    0
    [This post was marked as helpful]
    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>
     
    #2
      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)
      0
      Yikes. Thanks, because I never would have figured that one out.
       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9