<rss version="2.0">
  <channel>
    <title>Screencasts &amp;amp; HowTos on Mark Alldritt</title>
    <link>https://Alldritt.micro.blog/categories/screencasts-amp-howtos/</link>
    <description></description>
    
    <language>en</language>
    
    <lastBuildDate>Fri, 24 Jul 2009 11:05:44 -0700</lastBuildDate>
    
    <item>
      <title>Viewing Local Variables in Script Debugger</title>
      <link>https://Alldritt.micro.blog/2009/07/24/viewing-local-variables.html</link>
      <pubDate>Fri, 24 Jul 2009 11:05:44 -0700</pubDate>
      
      <guid>http://Alldritt.micro.blog/2009/07/24/viewing-local-variables.html</guid>
      <description>&lt;p&gt;The issue of how to view local variables (variables declared within an AppleScript handler) in Script Debugger keeps coming up.  This problem has been an issue ever since Script Debugger 2.0 when local variable display was introduced.  This issue surfaced again &lt;a href=&#34;http://lists.apple.com/archives/applescript-users/2009/Jul/msg00275.html&#34;&gt;recently on the AppleScript-Users mailing list&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;
Hello, how can I see the value of y in the variables pane of Script Debugger when I run this simple example script in debug mode:

set x to 3

beeping(x)

on beeping(x)
	--local y
	set y to 5
	beep x
	delay 2
	beep y
end beeping

Bert.
&lt;/pre&gt;
&lt;p&gt;Script Debugger requires all local variables be explicitly declared before they are displayed in the variables browser.  AppleScript allows you to explicitly declare locals in several ways:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;explicitly using the &amp;lsquo;local&amp;rsquo; statement&lt;/li&gt;
&lt;li&gt;as the loop variable in a &amp;lsquo;repeat with&amp;rsquo; statement&lt;/li&gt;
&lt;li&gt;as a parameter to a handler&lt;/li&gt;
&lt;li&gt;as a parameter to an &amp;lsquo;on error&amp;rsquo; statement&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The problem arrises when a variable is declared implicitly through an assignment within a handler.  In this instance, Script Debugger&amp;rsquo;s parser is not able to detect the new variable (y), and thus fails to display it in the variables browser.&lt;/p&gt;
&lt;p&gt;The solution is the uncomment the &amp;lsquo;local y&amp;rsquo; statement.&lt;/p&gt;
&lt;p&gt;&lt;object width=&#34;480&#34; height=&#34;385&#34;&gt;&lt;param name=&#34;movie&#34; value=&#34;http://www.youtube-nocookie.com/v/P0jF8262xe0&amp;hl=en&amp;fs=1&amp;rel=0&amp;color1=0x2b405b&amp;color2=0x6b8ab6&#34;&gt;&lt;/param&gt;&lt;param name=&#34;allowFullScreen&#34; value=&#34;true&#34;&gt;&lt;/param&gt;&lt;param name=&#34;allowscriptaccess&#34; value=&#34;always&#34;&gt;&lt;/param&gt;&lt;embed src=&#34;http://www.youtube-nocookie.com/v/P0jF8262xe0&amp;hl=en&amp;fs=1&amp;rel=0&amp;color1=0x2b405b&amp;color2=0x6b8ab6&#34; type=&#34;application/x-shockwave-flash&#34; allowscriptaccess=&#34;always&#34; allowfullscreen=&#34;true&#34; width=&#34;480&#34; height=&#34;385&#34;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;
&lt;p&gt;You can find &lt;a href=&#34;http://www.latenightsw.com/sd4/help/indexfolder/developfolder/debugfolder/variablesdebug.html&#34;&gt;additional information&lt;/a&gt; in the Script Debugger Help Book by searching for &amp;lsquo;local&amp;rsquo; from the Help menu.&lt;/p&gt;
&lt;p&gt;The AppleScript runtime does not provide public debugging hooks.  As a result, Script Debugger must resort to a series of hacks to implement step-wise debugging and variable display.  One of the limitations of this approach to AppleScript debugging is that Script Debugger must detect the names of all local variables at compile-time.  AppleScript&amp;rsquo;s support for multi-word identifiers in dictionaries makes parsing AppleScript source a very problematic thing to do, and makes detecting local variables without knowing AppleScript&amp;rsquo;s internal state impossible.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Script Debugger 4.5.3 On-Line Help as PDF</title>
      <link>https://Alldritt.micro.blog/2009/07/24/script-debugger-online.html</link>
      <pubDate>Fri, 24 Jul 2009 09:53:55 -0700</pubDate>
      
      <guid>http://Alldritt.micro.blog/2009/07/24/script-debugger-online.html</guid>
      <description>&lt;p&gt;Recently I have received several requests for Script Debugger 4.5&amp;rsquo;s On-Line help as a single PDF file.  &lt;a href=&#34;http://www.tidbits.com/matt/&#34;&gt;Matt Neuburg&lt;/a&gt;, who writes the Script Debugger 4 documentation, was able to oblige with a nicely hyperlinked PDF file.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&#34;http://www.latenightsw.com/archives/ScriptDebugger4.5.3Help.pdf&#34;&gt;Script Debugger 4.5.3 Help Book&lt;/a&gt;&lt;/strong&gt; (PDF, 3.9MB)&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Script Debugger 4.5 Can Take a Long Time to Open Scripts</title>
      <link>https://Alldritt.micro.blog/2009/01/17/script-debugger-can.html</link>
      <pubDate>Sat, 17 Jan 2009 18:49:25 -0700</pubDate>
      
      <guid>http://Alldritt.micro.blog/2009/01/17/script-debugger-can.html</guid>
      <description>&lt;p&gt;A few customers have written me to report that Script Debugger 4.5 takes much longer to open their scripts than did Script Debugger 4.0.&lt;/p&gt;
&lt;p&gt;This slowdown is an unintended consequence of a new feature in Script Debugger 4.5 where Script Debugger warns you that opening a script will cause other applications to be launched.&lt;/p&gt;
&lt;p&gt;This slowdown is most dramatic when opening scripts that target applications which have very large AppleScript dictionaries such as Adobe InDesign, Adobe Illustrator, or Microsoft Word.  Generally the delay should only be felt the first time Script Debugger 4.5 reads the dictionaries for these applications.  If Script Debugger is left running, it will reuse the dictionary information cached in memory.&lt;/p&gt;
&lt;p&gt;Script Debugger 4.5.1 introduced a new &amp;lsquo;Opening: Warn when applications may be launched&amp;rsquo; setting in the General Preferences panel that allows you to turn off the application launch warning when opening scripts.  If the delay opening your scripts is slowing down your work or if the warning becomes irritating, you can use this preferences setting to disable the feature.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://www.latenightsw.com/blog/wp-content/uploads/2009/01/prefs.jpg&#34; alt=&#34;Preferences&#34;&gt;&lt;/p&gt;
&lt;img src=&#34;https://Alldritt.micro.blog/uploads/2022/bbbb273c0c.jpg&#34; /&gt; 
</description>
    </item>
    
    <item>
      <title>Finding OSA scripts with Spotlight</title>
      <link>https://Alldritt.micro.blog/2008/07/09/finding-osa-scripts.html</link>
      <pubDate>Wed, 09 Jul 2008 23:31:12 -0700</pubDate>
      
      <guid>http://Alldritt.micro.blog/2008/07/09/finding-osa-scripts.html</guid>
      <description>&lt;p&gt;With the release of Script Debugger 4.0, I added a Spotlight searching capability for OSA scripts created with Script Debugger.  Based on a series of customer support emails I realized that this is not a well documented aspect of the product.  Here is a quick overview of how to use Script Debugger Spotlight support to find OSA scripts on your Macintosh.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: Spotlight indexing of OSA scripts only works for scripts that have beenn saved using Script Debugger.  Scripts created with Apple&amp;rsquo;s Script Editor are &lt;strong&gt;not&lt;/strong&gt; indexed.&lt;/p&gt;
&lt;p&gt;Script Debugger provides indexing information for three aspects of your OSA scripts:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;the source text of the script (kMDItemTextContent)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;the script&amp;rsquo;s description (kMDItemDescription)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;the script&amp;rsquo;s language name (kMDItemKeywords) which is normally &amp;ldquo;AppleScript&amp;rdquo;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here some ways to find all the scripts on your Macintosh which target the Apple Mail application.  First, we&amp;rsquo;ll search for documents containing &amp;ldquo;Mail&amp;rdquo; and with the AppleScript keyword:&lt;/p&gt;
&lt;p&gt; 
&lt;img src=&#34;https://Alldritt.micro.blog/uploads/2022/4ed4cfa0ba.jpg&#34;/&gt;&lt;/p&gt;
&lt;p&gt;This is good, but we get some documents that are not scripts.  Instead, we&amp;rsquo;ll search for OSA scripts that contain &amp;ldquo;Mail&amp;rdquo;:&lt;/p&gt;
&lt;img src=&#34;https://Alldritt.micro.blog/uploads/2022/0556c6171e.jpg&#34; /&gt;
&lt;p&gt;Perfect, all the OSA scripts on my machine that target the Apple Mail application.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Unix Newlines in Script Debugger</title>
      <link>https://Alldritt.micro.blog/2007/04/25/unix-newlines-in.html</link>
      <pubDate>Wed, 25 Apr 2007 18:10:11 -0700</pubDate>
      
      <guid>http://Alldritt.micro.blog/2007/04/25/unix-newlines-in.html</guid>
      <description>&lt;p&gt;I recently had a customer struggling to embed multi-line Unix shell scripts within their AppleScript script using Script Debugger.&lt;/p&gt;
&lt;p&gt;The problem is that Script Debugger&amp;rsquo;s default Newline character is CR (ASCII 13).  This is a historical relic dating back to the Classic Mac OS days.  When Apple introduced Script Editor 2, they changed the default newline from CR to LF.  We chose to stay with CR to avoid breaking existing scripts.&lt;/p&gt;
&lt;p&gt;This choice to remain with CR causes Script Debugger to operate differently from the Script Editor when editing multi-line string literals.  This is particularly a problem when you are trying to embed multi-line Unix scripts (sh, perl, ruby, python, etc.) which expect LF newlines into an AppleScript script.&lt;/p&gt;
&lt;p&gt;Fortunately, there is a solition.  You can change Script Debugger&amp;rsquo;s default Newline character using the following terminal command (make sure you quit Script Debugger before issuing it):&lt;/p&gt;
&lt;code&gt;
defaults write com.latenightsw.ScriptDebugger PrefEditorNewLineIsCR -bool no
&lt;/code&gt;
&lt;p&gt;Once this command has been issued, Script Debugger will insert LF characters whenever you press return.  When the newline character matters to you, I recommend also using the Show Invisibles command (View menu) to make Script Debugger show you the newline characters&lt;/p&gt;
&lt;p&gt;One final note: AppleScript converts LF newlines to CR in text &lt;em&gt;outside&lt;/em&gt; string literals and block commands when scripts are compiled or opened.  Here again, Script Debugger&amp;rsquo;s Show Invisibles feature will make it clear which newline character is being used where.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Avoiding Word &amp; Excel AppleEvent Crashes</title>
      <link>https://Alldritt.micro.blog/2007/02/01/avoiding-word-excel.html</link>
      <pubDate>Thu, 01 Feb 2007 09:05:34 -0700</pubDate>
      
      <guid>http://Alldritt.micro.blog/2007/02/01/avoiding-word-excel.html</guid>
      <description>&lt;p&gt;Microsoft Word and Excel can crash frequently when the Script Debugger Explorer is used.  These crashes can also be caused by AppleScript.  Here are some tips for avoiding many of these crashing bugs.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Turn off Script Debugger&amp;rsquo;s &amp;lsquo;Scan for elements of count fails&amp;rsquo; Dictionary preferences option&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Doing this will make it much less likely that Script Debugger&amp;rsquo;s Explorer will generate AppleEvents that cause Word or Excel to crash.&lt;/p&gt;
&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;Avoid using the Exists commands in your scripts&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I have found that asking Word or Excel if a non-existent object exists will very often cause a crash.  For example, if you open a new document and run the following script, Word will crash:&lt;/p&gt;
&lt;code&gt;
tell application &#34;Microsoft Word&#34;
	exists shape 1 of selection
end
&lt;/code&gt;
&lt;p&gt;The workaround is to use count:&lt;/p&gt;
&lt;code&gt;
tell application &#34;Micorosft Word&#34;
	try
		return count shapes of selection &gt;= 1
	on error
		return false
	end
end
&lt;/code&gt;
</description>
    </item>
    
  </channel>
</rss>