That’s right, JMP 10 ships with a brand new JSL Debugger. Say goodbye to the old and hello to the new! As I was wondering what I could say in a blog post about it, I started thinking about ways it makes my life as a JSL scripter easier. This post introduces a few wonderful features, and subsequent posts will zoom in on details.
The JSL Scripting Guide has a full description of the JSL Debugger, along with a few simple examples to get you started. In the meantime, here are some things to look forward to.
5. It Works!
That may be a bit harsh, but I found our previous JSL Debugger so limited in features and painful to use, I never used it. I now find myself abandoning my old habits of liberally sprinkling my code with Show()s, Print()s, and Write()s, and instead I turn to the new debugger. Which has the added benefit of not releasing my script to co-workers only to find I forgot to comment out or delete several Show()s.
As an added bonus, you don’t have to add /*debug step*/ to the top of your script to debug it. You can click the Debug Script toolbar button ( ) for your script — it’s right next to the Run Script button. Or select Edit>Debug Script. Or right-click in the script window and select Debug Script. Or press CONTROL-SHIFT-R (COMMAND-SHIFT-R on Macintosh). Easy!
4. It’s Available on Macintosh, Too
Oh, happy day! I can now debug JSL scripts on Macintosh as well as Windows! The debugger is the same one on both platforms. Same great features, same great functionality. I know my fellow Macintosh enthusiasts will welcome this, since the tired, old debugger wasn’t even available on Macintosh.
3. Debugging Loops and User-Written Functions
The days of selecting small pieces of code in your loops and running them piecemeal (while trying not to select the comma that resulted in a JSL error) are over. I can hear the cheers from here. As you run your code through the debugger, you can see the value of your iteration variable automatically updated each time it changes. You can use breakpoints to bypass the chunks you know are working. You can add a condition to a breakpoint and run through the first 200 iterations with one click, and then focus on where your trouble begins in the 201st iteration.
Debugging your functions is easier, too. You no longer have to separately declare whatever your “passed” variables are, and then run pieces of the function. You can just run the script to the function and step into it. The debugger shows you all values of the variables you pass in and the ones that are local to the function.
2. Stepping Into, Over, and Out of Code Blocks
Do you already know the expression you’re calling is flawless? Click Step Over in the debugger to run the expression with one click and stop at the next expression. Are you certain something is going wrong in your function? Click Step Into to enter the function and run each expression one at a time within the function. Are you halfway through stepping line by line through an Include() file and realize your problem isn’t here? Click Step Out to finish running the rest of the included script and return to debugging the expression that follows the Include().
1. Watching Variables
This was the one thing the old debugger did, but it was hard to use and limited. Variable-watching is a delight in the new debugger. The values of every single variable are shown in any scope that exists – global, local, here, namespaces. You don’t need to do a thing: It’s always there. As new variables are added in your code, they are added to the appropriate list. Add a new namespace, and a new list for it appears.
If you write lengthy scripts that use dozens of variables, those lists can get overwhelming. So flip over to the Watch tab.
You can add just the few variables you want to keep an eye on.
If you want to watch as values are added to a particular JSL list, you can subscript (for example, you can watch mylist).
You can scope in the watch list (for example, you can watch here:var and global:var at the same time).
You can type your variable name into the watch list, but it’s even easier to right-click on the variable name in the debugger’s script pane and select Add Watch.
Watch this space for more posts on the debugger, where I’ll discuss particular features and use cases in detail. Interested in a particular debugger topic? Mention it in the comments, and I’ll try to address it in a future post.