{"id":3898,"date":"2012-05-07T05:00:00","date_gmt":"2012-05-07T13:00:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=3898"},"modified":"2012-04-18T09:16:36","modified_gmt":"2012-04-18T17:16:36","slug":"primalscript-2012-whats-new-part-6","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2012\/05\/07\/primalscript-2012-whats-new-part-6\/","title":{"rendered":"PrimalScript 2012: What&#8217;s new? (Part 6)"},"content":{"rendered":"<p>VBScript users have told me on occasion that they are really jealous of one feature of PowerShell: Write-Debug<\/p>\n<p>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.<\/p>\n<p>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&#8217;t want to disable real output and not forget any diagnostic output.<\/p>\n<p>In PrimalScript 2012 VBScript and JScript users get help with that. Take a look at the following code:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/03\/image34.png\" width=\"614\" height=\"159\"><\/p>\n<p>&nbsp;<\/p>\n<p>The &#8216;TRACE comments are completely harmless and inactive if you just run the script. Execute that script in PrimalScript 2012&#8217;s debugger though and the output goes to the Debug pane. Think of it as a WScript.Debug.<br \/>You can use the same syntax and expressions you would normally use in a WScript.Echo call.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/03\/image35.png\" width=\"405\" height=\"157\"><\/p>\n<p>If you have to diagnose why the output from a SQL query fails after a few hundred records you certainly don&#8217;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.<\/p>\n<p>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.<\/p>\n<p>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?<\/p>\n<p>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&#8217;t affect your code at all. Obviously these are only active when your script runs in PrimalScript 2012&#8217;s debugger. They are available for VBScript, JScript and Windows PowerShell.<\/p>\n<p>Next time we take a look at some new code navigation tools in PrimalScript 2012.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[410,21,24,25],"tags":[193,487,28,700,219,996],"class_list":["post-3898","post","type-post","status-publish","format-standard","hentry","category-primalscript-software-news","category-software-news","category-vbscript","category-windows-powershell","tag-debugger","tag-jscript","tag-powershell","tag-primalscript-2012","tag-trace","tag-vbscript"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=3898"}],"version-history":[{"count":4,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3898\/revisions"}],"predecessor-version":[{"id":4159,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3898\/revisions\/4159"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=3898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=3898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=3898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}