Announcement

Collapse
No announcement yet.

Is Event Enabled ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • pgordon
    replied
    This works for me in VBSCRIPT

    sub main()
    const evenabled=&H20
    set ev = hs.GetEventEx("Event name goes here")
    evntenbl = ev.Misc AND evenabled
    if evntenbl= evenabled then msgbox "The event is currently disabled" 'if the result of the AND is = 32 then it is disabled
    if evntenbl = 0 then msgbox "The event is currently enabled" 'if the result of the AND is = 0, then it is enabled
    end sub

    HTH

    Paul G

    Leave a comment:


  • Wadenut
    replied
    OK.
    After a lot of Google-ing:
    This is a test script I managed to come up with. If there's a cleaner way to do this, please do comment.

    Sub Main(parm as object)
    dim ev as Scheduler.Classes.EventClass
    dim x,evntenbl as long
    dim enblval as long = 32
    x = hs.GetEventRefByName("Wunderground Data Update")
    ev = hs.GetEventByRef(x)
    evntenbl = ev.Misc AND enblval
    hs.writelog("test",evntenbl)
    End Sub


    What a NETmare!

    Leave a comment:


  • Wadenut
    replied
    Thanks Rick so far.
    Actually, if I wanted to enable or disable the event I too would, and do, use the shortcut method.

    What I need to do is read the value to determine whether or not the event is currently enabled. From that, I'll take some either/or action in my script.

    I'll re-read your reply, I may be able to figure it out from there, but in case not... --> ? <-- Could save me an evening of frustration, albeit a valuable learning experience.

    Further, this will be a VB .net script, where I believe SET won't work for me, correct?
    Last edited by Wadenut; November 21, 2008, 06:43 PM.

    Leave a comment:


  • Rick Tinker
    replied
    Let me help...

    MISC is a number, so just a bunch of 1's and 0's. The 1/0 in each position determines whether one of the MISC features is enabled or not. In your case, the bit at position 20H determines whether the event is enabled or not. This means that bit 6 needs to be flipped on/off to enable/disable the event because 20H = 0010 0000

    OK, so set up a const in your script to represent that bit value and you can use logic to turn it on or off:
    Const EvEnable = 32 ' 32 = Decimal value of 20 Hex

    So now we have a number where bit 6 is on, so if we OR that with any other value, it will turn on bit 6, but leave the other values unchanged, like this:
    0101 1001 Original Value
    0010 0000 EvEnable Value
    OR= 0110 1001

    To turn OFF the value, you will want to use an AND operation, but in this case we want to make sure that every bit is reversed so that the one we want to turn off is a zero and the ones we want left alone are 1's, so to do this we just NOT the value.

    So putting it all together you have this:

    dim ev
    dim x
    x = hs.GetEventRefByName("My Event")
    set ev = hs.GetEventByRef(x)

    'Enable the event:
    ev.Misc = ev.Misc OR evEnable
    'Disable the event
    ev.Misc = ev.Misc AND (Not evEnable)

    Hopefully that will help answer your question, but personally I would use the shortcut method:
    hs.EnableEvent("My Event")
    hs.DisableEvent("My Event")

    Leave a comment:


  • Wadenut
    started a topic Is Event Enabled ?

    Is Event Enabled ?

    I have a need (well, a desire) to determine within a script whether or not a particular event is enabled.

    I realize I'll need to do something like:

    x=hs.GetEventRefByName("My Event")
    y=hs.GetEventByRef(x)
    z=............?...............


    Here's where I'm lost.
    GetEventByRef returns an object of type EventClass which I have no clue at the moment how to use. I'll need to extract the bit "DISABLED = &H20" (where 1 = event disabled) from the property "misc".
    Can someone help me get my head around this and complete z= ?
    Thanks.
Working...
X