PrimalScript 2012: What’s new? (Part 6)
VBScript users have told me on occasion that they are really jealous of one feature of PowerShell: Write-Debug
Depending on the value of $DebugPreference this produces output when needed but makes it easy to silence diagnostic output once a script moves to production.
VBScript and JScript developers have to sprinkle WScript.Echo calls through their code and then go and comment them out before handing the script off. In a large script with hundreds or even thousands of lines that can be a daunting and error prone task. You don’t want to disable real output and not forget any diagnostic output.
In PrimalScript 2012 VBScript and JScript users get help with that. Take a look at the following code:
The ‘TRACE comments are completely harmless and inactive if you just run the script. Execute that script in PrimalScript 2012’s debugger though and the output goes to the Debug pane. Think of it as a WScript.Debug.
You can use the same syntax and expressions you would normally use in a WScript.Echo call.
If you have to diagnose why the output from a SQL query fails after a few hundred records you certainly don’t want to sit there and single step through this or hit a breakpoint in each loop iteration. Add a TRACE statement to output unique field and when the script stops you see the last output and can easily take it from there.
Those of you paying attention have also already spotted the blue dot in the first screenshot and correlated it with the Tracepoint output in the second screenshot.
Tracepoints can be set and removed using Ctrl+F9 and are just as persistent as breakpoints if the file resides on an NTFS partition. So what are they for?
If you have a long running script and you are testing it you need some feedback if the script is actually moving along or is hanging somewhere. You can of course add a trace statement or a write-debug in PowerShell, but why type if you just need confirmation that your script is whizzing by a certain milestone. Adding a tracepoint is a single key combination and doesn’t affect your code at all. Obviously these are only active when your script runs in PrimalScript 2012’s debugger. They are available for VBScript, JScript and Windows PowerShell.
Next time we take a look at some new code navigation tools in PrimalScript 2012.