Search code examples
lotus-dominolotusscript

How to test that agent is running In Debug?


Is there a way to know that an agent in running in debug mode (Tools/Debug LotusScript has been activated) ?

I found nothing in NotesAgent class, something like RunOnServer but RunInDebugger.

I need this to avoid using the progress bar function located in NNOTESWS.DLL, which pops over the debugger and prohib any click (step into, or watching variables). BTW if it occurs to someone you still can press F8 / F5, this help at least not to kill Notes.


Solution

  • There Is a very good example for doing this in OpenNTF. You can find it here.

    And in fact it IS for the progress bar, so you can use tho whole class from there.

    The trick is: you add a function with a stop statement. You measure the time before the stop statement and after. If the time passed is bigger than 100ms, than a user had to click on "continue", what he never manages to do in such a small amount of time. If debugger is not enabled, the stop is ignored - no delay...

    Here is the function used in the linked openntf article:

    Public Function IsDebugMode() As Boolean
      Dim start As Variant
      start = Getthreadinfo(6) ' LSI_THREAD_TICKS
      Stop
      If Getthreadinfo(6) - start > 100 Then IsDebugMode = True
      ' If you debug the application you will not be able to press the CONTINUE-Buton 
      ' within less then 100 milliseconds, otherwise the STOP-statement is not in function
      ' and you will always be quicker then 100 milliseconds
    End Function
    

    Although the comment is in fact wrong (100 tics are not 100ms, you would have to devide by ticks per second to get that value), the code still works and does exactly what you want.