Link to home
Start Free TrialLog in
Avatar of TRArter
TRArter

asked on

Can LotusScript detect automatically if the Script Debugger is enabled?

Hi Experts

I have a LotusScript agent which contains an error handler, called by the statement:

On Error goto errorhandler

When using the LotusScript debugger, I don't want to use the error handler, but want the script to stop on the line with the error (so I can check the variables)

When the debugger is disabled, i want the script to use the error handler.

Is there a way for LotusScript to automatically detect if the debugger is enabled?

Thanks
Trevor
Avatar of marilyng
marilyng

Well, could be the $100 question.    

I don't know of a way, other than to set a global Debug = True and then code accordingly:  

if DEBUG then
               On error goto thisPlace
end if

Oops, If NOT DEBUG then do this..
Avatar of TRArter

ASKER

Naturally I did that. I was hoping that it could be FULLY automatic
Avatar of Steve Knight
[Wild speculation]
Might be worth a check of notes.ini.

I seem to remember there is a "debugwindowsplit" type entry which presuambly gets recorded when debug starts up.  You could clear that entry from notes.ini at the beginning of your script then if it comes back debug is open (maybe).  Don't know at what point that gets written back to notes.ini

To test ()I haven't got notes here) Clear entry out of notes.ini, take a copy of the file , let debug kick in and fc.exe the two INI files to see if any changes.

As Marilyn's idea, I tend to use a flag of some kind, i.e. a particular notes.ini entry or userrole [Debug] etc. that I can give myself for test purposes like this but of course that isn't automatic on debug entry...

Steve
Nice try, NoShowDialogDebug=1 or debugwindowsplit don't change when debugger is on or off.  You would think there has to be some flag set somewhere.. interesting to look in ini, though.
Avatar of TRArter

ASKER

Yeah. i would think there has to be some flag set somewhere! But where?
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just a hunch: maybe you can do something with GetActiveWindow?
    Declare Function GetActiveWindow Lib "user32.dll" () As Long
    Declare Function GetForegroundWindow Lib "user32" () As Long
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (Byval hwnd As Long, Byval lpString As String, Byval cch As Long) As Long

    Dim sCurText As String * 255
    Dim i As Integer
    Dim lHwnd As Long
   
    lHwnd = GetForegroundWindow
    i= GetWindowText(lHwnd, Byval sCurText, 255)
    sCurText= Trim(Left$(sCurText, i))

Maybe the name differs when you're in the debugger??
Avatar of TRArter

ASKER

Sjef comes up with the goods again!

Setting the DEBUG variable manually in the debugger allows me to turn the error handler on and off without changing the code, which is what I wanted.

I didn't know you could do that. Thanks!

Thanks to the rest of you for your suggestions as well

All the best
Trevor
Heh, can you do that?  Must have a play!

Steve
> Heh, can you do that?

I'd rather say: is that all you can do?? I think the level of interaction with the debugger is rather poor, compared to the M$ Visual VB/C products. There are even debuggers that allow you to change code "on the fly". And every now and then the debugger causes a crash of the Notes client. For the rest, no complaints.
True.  It's not as flakey as the formula language debugger though ;-)
Just "flakey"? You're too kind :-))
Avatar of TRArter

ASKER

What formula language debugger?
The one they scrapped from R5 to R6... :-)
Avatar of TRArter

ASKER

I thought that's what you were going to say, but "hope springs eternal in the human breast" (or was it beast?)
And they did so for a very good reason: it was a very good idea, but it was buggy as hell!