mIRC Home    About    Download    Register    News    Help

Topic Options
#261765 - 24/11/17 07:32 AM Monitoring script execution
goblin58 Offline
Nutrimatic drinks dispenser

Registered: 22/11/17
Posts: 9
Is there a way to monitor script execution? I have a weird defect in a script where the script works fine locally but not remotely.

I would like to avoid writing to a file however if I have to I will.

Can I attach a debugger to mIrc and watch script execution and inspect call stacks and variables etc?

Any advice would be greatly appreciated.

Top
#261766 - 24/11/17 07:55 AM Re: Monitoring script execution [Re: goblin58]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 970
I don't have an answer about the debugger, but when you say local/remote, are you talking about remote being in a script in the alt-R window and local meaning a command run from the channel editbox? If so, perhaps if you showed a sample command someone could identify the defect that may not turn out to be so weird.

Top
#261768 - 24/11/17 08:48 AM Re: Monitoring script execution [Re: maroon]
goblin58 Offline
Nutrimatic drinks dispenser

Registered: 22/11/17
Posts: 9
Sorry, I added some confusion there. I mean when I run the script in the mIRC client where the script is loaded it works fine, however when I run the same script from a different client it fails. Does that make sense?

I can't really post a code snippet as I do not know where the script is failing and the script is getting quite large and there are many support aliases required to run it.

Top
#261771 - 24/11/17 09:22 AM Re: Monitoring script execution [Re: goblin58]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 970
The debugger I use is to add echo statements within scripts in a way that doesn't otherwise alter the way the script runs. Something like:

echo -s $asctime($ctime,[HH:nn:ss]) $nopath($script) $scriptline

You can place these in as many places as you wish, helping you determine whether your script branched the expected way on an if() statement, is triggered by an event, etc. You can also include %variables, identifiers like $event or $ctimer to help trace why your script is glitching. If you want to echo a command where the variables and results of $iif() etc are replicated in the display, you sometimes need to add spaces to allow $identifiers and $variables to display their true values even though an if() statement can correctly function without.

If you don't want your debug messages being lost in the status window clutter, you can send the output to a @window instead using aline instead of echo. Check /help for any switches you might find helpful, like 'aline -p @window'.

If you use a consistent format for your debug messages, you can easily identify which message from which script is showing, allowing you to trim them when your glitch is fixed.

In some cases you'll want to have conditional logic to limit debug messages to certain conditions. For example if you have a debug message inside a dialog, showing debug messages for every 'mouse' $devent will flood your debug window.

To add debug messages sometimes requires adding brackets around existing code to make it behave the same way. For example, debugging this:

if (%var123 == 1) goto label

would need to change to something like:

if (%var123 > %var456) { echo -t @debug $nopath($script) $scriptline var123 %var123 var456 %var456 | goto label }

Sometimes the presence of your debug messages can slow down a script enough to prevent a glitch if inserting slow debug messages delay the code enough to prevent a timing-related problem, but that's rare.

Top
#261773 - 24/11/17 09:32 AM Re: Monitoring script execution [Re: maroon]
goblin58 Offline
Nutrimatic drinks dispenser

Registered: 22/11/17
Posts: 9
Thanks a great explanation of using echo. I use echo extensively, the issue I have is that when a user calls my bot script the echo's don't show in my bot's window (as described by mIrc help) frown

I guess I'll have to write the code execution messages (echo messages) to a text file instead then write a small windows program to monitor the file and display new data, actually I think notepad++ does that anyway.

Top
#261774 - 24/11/17 10:26 AM Re: Monitoring script execution [Re: goblin58]
goblin58 Offline
Nutrimatic drinks dispenser

Registered: 22/11/17
Posts: 9
Yikes! Sometimes I can't see the wood for the trees, the echo works just fine. It was my ON TEXT that was wrong. *facepalms*

Now to debug!

Top