<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>output stream</title>
	
	<link>http://duncanandmeg.org/blogs/code</link>
	<description>riotous events in amateur development</description>
	<lastBuildDate>Fri, 18 Feb 2011 21:28:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/DJCode" /><feedburner:info uri="djcode" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Exporting bibliography from library catalog to XML</title>
		<link>http://feedproxy.google.com/~r/DJCode/~3/J64UPouXWpY/</link>
		<comments>http://duncanandmeg.org/blogs/code/2011/02/08/exporting-bibliography-from-library-catalog-to-xml/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 18:58:58 +0000</pubDate>
		<dc:creator>dtjohnso</dc:creator>
				<category><![CDATA[XML & XSL]]></category>

		<guid isPermaLink="false">http://duncanandmeg.org/blogs/code/?p=151</guid>
		<description><![CDATA[As part of a LibGuide project that I was working on recently, I wanted to export the bibliographic data for rare Bibles in our Mack Library collection so that I could generate a list for public viewing. The rare Bibles in our collection are housed in two rooms, the Jerusalem Chamber and Special Collections, and [...]]]></description>
			<content:encoded><![CDATA[<p>As part of a <strike>LibGuide</strike> project that I was working on recently, I wanted to export the bibliographic data for rare Bibles in our Mack Library collection so that I could generate a list for public viewing. The rare Bibles in our collection are housed in two rooms, the Jerusalem Chamber and Special Collections, and because few people ever see the books in Special Collections I thought it would be nice to create a browsable list. Our current library catalog does not make it possible to browse the items in a particular room (or &#8220;location code&#8221; in library science terms).</p>
<p>The process I came up with involves three major components:
<ol>
<li>Finding and exporting the bibliographic records in Millennium using Create Lists</li>
<li>Filtering, finalizing, and structuring the data in Excel 2007</li>
<li>Converting the structured data into clean HTML with XSLT</li>
</ol>
<p>I&#8217;ve posted my files in a <a href="https://github.com/dtjohnso/Millennium-XML-HTML-conversion" class="liexternal">github repo</a> for others to adapt.</p>
<h4>Step 1: Export records from Millennium</h4>
<p>To create my list, I did an item record search based on location code, but stored the bib records in my list.<br />
<a href="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/1.1-millennium-search.png" class="liimagelink"><img src="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/1.1-millennium-search-300x260.png" alt="" title="1.1 millennium search" width="300" height="260" class="alignnone size-medium wp-image-159" /></a></p>
<p>I then exported all the data to text. Because some of the variable-length fields included commas, I used tabs (&#8220;Control character&#8221; 9) as my field delimiter.<br />
<a href="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/1.2-millennium-export.png" class="liimagelink"><img src="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/1.2-millennium-export-267x300.png" alt="" title="1.2 millennium export" width="267" height="300" class="alignnone size-medium wp-image-160" /></a></p>
<h4>Step 2: Manipulation in Excel 2007</h4>
<p>For my situation, data processing in Excel involved a number of small steps. Steps 2.2 and 2.3 may not be necessary for every use case.</p>
<h5>2.1 Import data</h5>
<p>A number of the titles in our collection are not in English, and so I had to specify that the imported data was Unicode (UTF-8). I found out that Excel 2003 does not support importing UTF-8, but Excel 2007 does.</p>
<p><a href="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/2.1-import-unicode.png" class="liimagelink"><img src="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/2.1-import-unicode-300x212.png" alt="" title="2.1 import unicode" width="300" height="212" class="alignnone size-medium wp-image-180" /></a></p>
<p>On step 3 of the import wizard, I set the data format for all columns as &#8220;Text&#8221; rather than &#8220;General&#8221; to avoid any unwanted conversion of my bibliographic data.</p>
<p><a href="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/2.2-import-as-text.png" class="liimagelink"><img src="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/2.2-import-as-text-300x212.png" alt="" title="2.2 import as text" width="300" height="212" class="alignnone size-medium wp-image-181" /></a></p>
<h5>2.2 Filter records (if necessary)</h5>
<p>Because our Special Collections room includes many items besides the Bibles that I was interested in, I needed to filter my data. I did a quick filter for all items with Uniform Titles beginning with &#8220;Bible.&#8221; and used <a href="http://www.lytebyte.com/2008/02/08/how-to-select-and-copy-only-visible-cells-columns-or-rows-in-ms-excel-2007-and-2003/" target="_blank" class="liexternal">Select Visible Cells</a> to copy and paste the data I wanted to a new worksheet to prepare for export.</p>
<h5>2.3 Produce truncated bibID</h5>
<p>The current version of the Innovative Web catalog at my institution does not respond correctly to a full 9 character bibID. Instead, I have to truncate the checkdigit at the end to get a valid link. Now, since that may not make much sense, let me just illustrate:
<ul>
<li><a href="http://library.bju.edu/record=b1184983" class="liexternal">http://library.bju.edu/record=b1184983</a> <b>VALID</b></li>
<li><a href="http://library.bju.edu/record=b11849836" class="liexternal">http://library.bju.edu/record=b11849836</a> &#8211; <b>INVALID</b> (at least, for now)</li>
</ul>
<p>The first example does not include the checkdigit &#8220;6&#8243; at the end. Since the checkdigit is included in the data exported by Millennium, I created a new column at the end of my data and populated it with this Excel formula:</p>
<pre><code class=\'prettyprint\'  class="prettyprint">=LEFT(A2,8)</code></pre>
<p>where &#8220;A2&#8243; is the reference to the cell containing the untruncated bibID.</p>
<h5>2.4 Match columns to XML Schema</h5>
<p>In order to prepare my data for export, I need to match each column to an attribute in a custom XML Schema so I can export structured data that I can meaningfully interpret into HTML.</p>
<p>To do this, I&#8217;ll need to create my schema file, load into Excel, and match each element to the appropriate data columns.</p>
<p>My XSD is as follows, and can be easily adapted to another situation.</p>
<pre><code class=\'prettyprint\'  class="prettyprint">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;schema xmlns="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;element name="Bibliography"&gt;
    &lt;complexType&gt;
      &lt;sequence&gt;
        &lt;element name="Item" maxOccurs="unbounded"&gt;
          &lt;complexType&gt;
            &lt;sequence&gt;
              &lt;element name="ItemTitle" type="string" /&gt;
              &lt;element name="ItemUniformTitle" type="string" /&gt;
              &lt;element name="ItemAuthor" type="string" /&gt;
              &lt;element name="ItemCallNum" type="string" /&gt;
              &lt;element name="ItemEdition" type="string" /&gt;
              &lt;element name="ItemPublication" type="string" /&gt;
              &lt;element name="ItemDescription" type="string" /&gt;
              &lt;element name="ItemSeries" type="string" /&gt;
              &lt;element name="ItemNote" type="string" /&gt;
              &lt;element name="ItemSubject" type="string" /&gt;
              &lt;element name="ItemAddAuthor" type="string" /&gt;
              &lt;element name="ItemAddTitle" type="string" /&gt;
              &lt;element name="ItemISBN" type="string" /&gt;
              &lt;element name="ItemTOC" type="string" /&gt;
              &lt;element name="ItemBibID" type="string" /&gt;
              &lt;element name="ItemBibIDTruncated" type="string" /&gt;
            &lt;/sequence&gt;
          &lt;/complexType&gt;
        &lt;/element&gt;
      &lt;/sequence&gt;
    &lt;/complexType&gt;
  &lt;/element&gt;
&lt;/schema&gt;</code></pre>
<p>Once I have a valid schema, I load it into Excel through XML Source window on the Developer ribbon. To add a new Schema, click the &#8220;XML Maps&#8221; button and then &#8220;Add.&#8221; Then I drag each attribute in the XML tree visible in the XML Source pane and drop it on the appropriate column in my data until the result looks like this:<br />
<a href="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/2.4-XML-source.png" class="liimagelink"><img src="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/2.4-XML-source-300x217.png" alt="" title="2.4 XML source" width="300" height="217" class="alignnone size-medium wp-image-182" /></a></p>
<h5>2.5 Export to XML</h5>
<p>To generate XML from my formatted file, I click the &#8220;Export&#8221; button in the XML section of the Developer ribbon and save to file. Excel will follow my custom schema to produce structured data that I can use to generate HTML output.<br />
<a href="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/2.5-export.png" class="liimagelink"><img src="http://duncanandmeg.org/blogs/code/wp-content/uploads/2011/02/2.5-export-300x206.png" alt="" title="2.5 export" width="300" height="206" class="alignnone size-medium wp-image-183" /></a></p>
<h4>Step 3: Generate HTML with XSLT</h4>
<p>Now that my data is in XML, generating HTML is a simple matter of applying an XSL stylesheet. My stylesheet is as follows:</p>
<pre><code class=\'prettyprint\'  class="prettyprint">&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="html" indent="no" encoding="UTF-8"/&gt;
  &lt;xsl:template match="/Bibliography"&gt;
    &lt;xsl:apply-templates select="Item"&gt;
      &lt;xsl:sort data-type="text" select="ItemUniformTitle" order="ascending" /&gt;
    &lt;/xsl:apply-templates&gt;
  &lt;/xsl:template&gt;
  &lt;xsl:template match="Item"&gt;
    &lt;p&gt;
      &lt;xsl:variable name="bibID" select="ItemBibIDTruncated"/&gt;
        &lt;xsl:choose&gt;
          &lt;xsl:when test="ItemUniformTitle != ''"&gt;
            <b>&lt;xsl:value-of select="ItemUniformTitle" /&gt;</b>
            &lt;xsl:text&gt; &lt;/xsl:text&gt;
            &lt;xsl:value-of select="ItemTitle"/&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:otherwise&gt;
            <b>&lt;xsl:value-of select="ItemTitle"/&gt;</b>
          &lt;/xsl:otherwise&gt;
        &lt;/xsl:choose&gt;
        &lt;xsl:text&gt; &lt;/xsl:text&gt;
        &lt;xsl:value-of select="ItemPublication" /&gt;
        &lt;xsl:text&gt; [&lt;/xsl:text&gt;
        <a href="http://library.bju.edu/record={$bibID}" target="_blank">
          &lt;xsl:value-of select="ItemCallNum" /&gt;
        </a>]&lt;xsl:text/&gt;
        &lt;xsl:if test="ItemNote != ''"&gt;
          &lt;br/&gt;
          <i>
            &lt;xsl:value-of select="ItemNote"/&gt;
          </i>
        &lt;/xsl:if&gt;
    &lt;/p&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://duncanandmeg.org/blogs/code/2011/02/08/exporting-bibliography-from-library-catalog-to-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://duncanandmeg.org/blogs/code/2011/02/08/exporting-bibliography-from-library-catalog-to-xml/</feedburner:origLink></item>
		<item>
		<title>How to easily add customized links to an intranet page</title>
		<link>http://feedproxy.google.com/~r/DJCode/~3/qCa-rPu75LY/</link>
		<comments>http://duncanandmeg.org/blogs/code/2009/12/11/how-to-easily-add-customized-links-to-an-intranet-page/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 21:50:56 +0000</pubDate>
		<dc:creator>dtjohnso</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://duncanandmeg.org/blogs/code/?p=72</guid>
		<description><![CDATA[For a long time, I always wished I had an easy way to add a custom set of links to my university&#8217;s intranet home page so I could easily access the pages for my current classes. The idea was to have it look something like the image below. Notice the &#8220;Class Links&#8221; section above &#8220;Home.&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>For a long time, I always wished I had an easy way to add a custom set of links to my university&#8217;s intranet home page so I could easily access the pages for my current classes.</p>
<p>The idea was to have it look something like the image below. Notice the &#8220;Class Links&#8221; section above  &#8220;Home.&#8221; The original page only had the &#8220;Home&#8221; section.</p>
<p style="text-align: center;"><img class="size-medium wp-image-73 aligncenter" title="Class links" src="http://duncanandmeg.org/blogs/code/wp-content/uploads/2009/12/endresult.png" alt="Custom class links embedded into my campus home page" width="300" height="201" /></p>
<p>Originally, this seemed to be a bit implausible. Now, thanks to <a href="https://addons.mozilla.org/en-US/firefox/addon/748" class="liexternal">Greasemonkey</a> and <a href="http://instapaper.com" class="liexternal">Instapaper</a>, it&#8217;s actually pretty easy. In fact, the solution I&#8217;ve built is general enough that it could be easily adapted to a number of similar situations where you want an easy way to personalize a set of links on a non-interactive page.</p>
<p>I thought that some of my classmates might be interested in this, so this post is to explain how to adapt my code for yourself. This will require some very basic JavaScript skills at one point, but hopefully I&#8217;ll be able to make that part easy enough.<span id="more-72"></span></p>
<h4>Step 1: Create a list of course pages at instapaper.com</h4>
<p>To begin with, you&#8217;ll need to have an account on instapaper.com. This is where you&#8217;ll store links to your class home pages. If you don&#8217;t have an account, <a href="http://www.instapaper.com/user/register" class="liexternal">sign up now</a>.</p>
<ol>
<li><img class="alignright size-full wp-image-101" title="folders" src="http://duncanandmeg.org/blogs/code/wp-content/uploads/2009/12/folders.png" alt="folders" width="185" height="192" />Once you&#8217;re logged in to instapaper, you&#8217;ll need to make a folder in instapaper to store your class links. I named mine &#8220;Classes.&#8221; You can see an example of my folder structure on the right.</li>
<li>Next, you&#8217;ll need to add the links you want to the Classes folder. Do this by clicking on the folder and using the link to the <a href="http://www.instapaper.com/edit" class="liexternal">&#8220;+ Add&#8221; form</a> at the top of the page, or with the instapaper bookmarklet.</li>
<li>Once you have the links displaying in your &#8220;Classes&#8221; folder as you want them to appear on the school home page, go to the RSS link at the bottom of the page. You&#8217;ll want to copy the RSS feed&#8217;s URL somewhere so you can paste it into your Greasemonkey script in the next step.</li>
</ol>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-105" title="rssURL" src="http://duncanandmeg.org/blogs/code/wp-content/uploads/2009/12/rssURL.png" alt="rssURL" width="389" height="283" /></p>
<h4>Step 2: Install Greasemonkey script</h4>
<p>Now that your links are stored in instapaper, you&#8217;ll need to install my Greasemonkey script to insert them onto the intranet home page. If you don&#8217;t have the Greasemonkey extension installed in your Firefox, go to the <a href="https://addons.mozilla.org/en-US/firefox/addon/748" class="liexternal">Greasemonkey extension page</a> and take care of that.</p>
<p>This step is somewhat more technical, but once done on the computers where you want your links to appear you will never have to do this part again. </p>
<ol>
<li><img class="size-full wp-image-110 alignright" title="newuserscript" src="http://duncanandmeg.org/blogs/code/wp-content/uploads/2009/12/newuserscript.PNG" alt="newuserscript" width="213" height="110" />To begin with, you&#8217;ll need to create a new Greasemonkey script in Firefox. Do this by right-clicking the Greasemonkey icon in the Firefox status bar and selecting &#8220;New user script&#8230;&#8221;</li>
<li>Fill in the box that pops up with the values below.<br />
<blockquote><p><strong>Name: </strong>Insert class links from remote location<br />
<strong>Namespace: </strong>http://www.duncanandmeg.org/<br />
<strong>Includes (one per line):<br />
</strong>http://home.bju.edu/</p>
<p>https://home.bju.edu/</p></blockquote>
</li>
<li>Get the <a href="http://gist.github.com/177199" class="liexternal">current copy of my script from here</a> and paste it in over the new file that pops up on your screen. Save your file.</li>
<li>Find the line in your script that looks like the one below and paste the URL for your instapaper folder&#8217;s RSS feed over my URL.
<p>
<pre><code class=\'prettyprint\' >var feedURL = "http://www.instapaper.com/folder/48337/rss/11185/QBV0RZfH4KBO7GwgrR3D8b7sv90";</code></pre>
</p>
</li>
<li>Save your script and close it.</li>
</ol>
<h4>Finished!</h4>
<p>Now go to the <a href="http://home.bju.edu/" class="liexternal">home.bju.edu</a> to test your script. It should insert a list of class links into the page based on the contents of your folder in instapaper.</p>
<p>In the future, you will not need to edit the Greasemonkey script again. Any changes you make to the contents of your instapaper folder will be automatically reflected in the links displayed on the intranet home page.</p>
]]></content:encoded>
			<wfw:commentRss>http://duncanandmeg.org/blogs/code/2009/12/11/how-to-easily-add-customized-links-to-an-intranet-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://duncanandmeg.org/blogs/code/2009/12/11/how-to-easily-add-customized-links-to-an-intranet-page/</feedburner:origLink></item>
		<item>
		<title>Birthday surprise</title>
		<link>http://feedproxy.google.com/~r/DJCode/~3/IN9F4hl9h1k/</link>
		<comments>http://duncanandmeg.org/blogs/code/2009/03/03/birthday-surprise/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 19:00:22 +0000</pubDate>
		<dc:creator>dtjohnso</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://duncanandmeg.org/blogs/code/?p=64</guid>
		<description><![CDATA[My wife and I wrote this little program for my little brother, who is a freshman computer science major. It was a lot of fun, and brought back memories of my C++ days in school. Obviously the programming wasn&#8217;t challenging, but getting the parameters right was a lot of fun. #include &#38;lt;iostream&#38;gt; #include &#38;lt;windows.h&#38;gt; #define [...]]]></description>
			<content:encoded><![CDATA[<p>My wife and I wrote this little program for my little brother, who is a freshman computer science major. It was a lot of fun, and brought back memories of my C++ days in school.</p>
<p>Obviously the programming wasn&#8217;t challenging, but getting the parameters right was a lot of fun.</p>
<pre><code class=\'prettyprint\'  class="prettyprint">#include &amp;lt;iostream&amp;gt;
#include &amp;lt;windows.h&amp;gt;

#define doo 262 //frequency do 262 Hz
#define re 294 //frequency re 294 Hz
#define mi 330 //frequency mi 330 Hz
#define fa 349 //frequency fa 349 Hz
#define sol 392 //frequency sol 392 Hz
#define la 440 //frequency la 440 Hz
#define si 495 //frequency si 495 Hz
#define od 523 //frequency do 523 Hz

using namespace std;

int main()
{  

  Beep(doo,100);
  Beep(doo,100);
  Beep(re,180);
  Beep(doo,190);
  Beep(fa,200);
  Beep(mi,300);
  Beep(doo,100);
  Beep(doo,100);
  Beep(re,180);
  Beep(doo,190);
  Beep(sol,220);
  Beep(fa,300);
  Beep(doo,100);
  Beep(doo,100);
  Beep(od,260);
  Beep(la,260);
  Beep(fa,220);
  Beep(mi,200);
  Beep(re,300);
  Beep(466,100); //b-flat is 2^(1/12)*440 http://en.wikipedia.org/wiki/Note#Note_frequency_.28hertz.29
  Beep(466,100); //b-flat is 2^(1/12)*440 http://en.wikipedia.org/wiki/Note#Note_frequency_.28hertz.29
  Beep(la,260);
  Beep(fa,300);
  Beep(sol,300);
  Beep(fa,300);

  return 1;
}</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://duncanandmeg.org/blogs/code/2009/03/03/birthday-surprise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://duncanandmeg.org/blogs/code/2009/03/03/birthday-surprise/</feedburner:origLink></item>
		<item>
		<title>Microsoft LifeCam VX-3000: Installation &amp; configuration</title>
		<link>http://feedproxy.google.com/~r/DJCode/~3/fYqHo2MN7m0/</link>
		<comments>http://duncanandmeg.org/blogs/code/2008/12/26/microsoft-lifecam-vx-3000-installation-configuration/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 23:27:28 +0000</pubDate>
		<dc:creator>dtjohnso</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[microsoft lifecam vx-3000]]></category>

		<guid isPermaLink="false">http://duncanandmeg.org/blogs/code/?p=56</guid>
		<description><![CDATA[In a recent post, I wrote about our new webcam and mentioned some incompatibilities I discovered. Here I want to document how I installed and configured the software for the camera, mostly so my family can re-install the camera if they ever need to do so. These notes refer to how I did this on [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://duncanandmeg.org/blogs/code/2008/12/26/microsoft-lifecam-vx-3000-overview/" class="liinternal">recent post</a>, I wrote about our new webcam and mentioned some incompatibilities I discovered. Here I want to document how I installed and configured the software for the camera, mostly so my family can re-install the camera if they ever need to do so. These notes refer to how I did this on a Windows XP system.<span id="more-56"></span></p>
<h3>Installing the proprietary software</h3>
<p>The software included on the CD is pretty easy to install and configure. The disk includes the camera drivers and a copy of the Microsoft LifeCam program which provides basic webcam functions. I used it to test the webcam itself, but nothing else.</p>
<p>The instructions recommend that you install the software on the CD before plugging the camera in. I did this, but I have another theory that I&#8217;ll try on my computer at home.<sup><a href="http://duncanandmeg.org/blogs/code/2008/12/26/microsoft-lifecam-vx-3000-installation-configuration/#footnote_0_56" id="identifier_0_56" class="footnote-link footnote-identifier-link" title="My theory is that if I plug the camera in without installing the Microsoft software at all, I can probably load the driver by itself into Windows from the CD using the Found New Hardware wizard. If this works, I&amp;#8217;ll write another report explaining how.">1</a></sup> Once the LifeCam software and drivers are loaded, the installer prompts you to install the Windows Live Messenger (which includes a component called Windows Live Call). This is the Microsoft software for making video calls. I installed this, but when I installed Skype later I disabled the Live Call functionality (more below).</p>
<h3>Configuring Skype</h3>
<p>I <a href="http://www.skype.com/" class="liexternal">downloaded and installed Skype</a> using all the default settings. Skype detected the camera automatically, so I really didn&#8217;t have to configure anything within Skype for the camera to work.</p>
<h4>One-touch button</h4>
<p>I found one <a href="http://forum.skype.com/lofiversion/index.php/t68022.html" class="liexternal">helpful hack on the Skype user forums</a> that explains how to make the &#8220;Live Call&#8221; one-touch button on top of the camera work with Skype instead of the default Windows Live Call program. The Skype forums report two ways to do this, one by substituting the Skype executable for the Live Call program, and the other by making edits to the Windows registry.</p>
<p>The only problem with the registry hack method (which has detailed explanation <a href="http://forum.skype.com/index.php?showtopic=71083" class="liexternal">here</a>) is that you may have to edit multiple entries underneath different numbers which refer to which USB port the camera is plugged into. Since there&#8217;s a good chance that my family may unplug the camera for some reason and then plug it in somewhere else, I decided to use the substitute executable method. One other commenter mentions a fascinating (and probably better) method <a href="http://forum.skype.com/index.php?showtopic=71083&amp;view=findpost&amp;p=575351" class="liexternal">using a symlink for Windows Vista</a>, but it won&#8217;t work for XP. (If this paragraph doesn&#8217;t make sense to you, ignore it!)</p>
<p>Here are the steps I used for the substitute executable method. Essentially, this disables Windows Live Call, so it would be a good idea to remove all shortcuts to Live Call after following this hack:</p>
<ol>
<li>Open the folder C:\Program Files\Microsoft LifeCam\</li>
<li>Rename IcePick.exe (the &#8220;Live Call&#8221; executable) to IcePick.exe.bak</li>
<li>Copy skype.exe to this folder and rename it to IcePick.exe</li>
</ol>
<p>Even when Skype is running in the background, pushing the one-touch button on top of the camera brings it up for making calls.</p>
<p class="footnotes">NOTES:</p><ol class="footnotes"><li id="footnote_0_56" class="footnote">My theory is that if I plug the camera in without installing the Microsoft software at all, I can probably load the driver by itself into Windows from the CD using the Found New Hardware wizard. If this works, I&#8217;ll write another report explaining how.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://duncanandmeg.org/blogs/code/2008/12/26/microsoft-lifecam-vx-3000-installation-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://duncanandmeg.org/blogs/code/2008/12/26/microsoft-lifecam-vx-3000-installation-configuration/</feedburner:origLink></item>
		<item>
		<title>Microsoft LifeCam VX-3000: Overview</title>
		<link>http://feedproxy.google.com/~r/DJCode/~3/wYtckWTTZkU/</link>
		<comments>http://duncanandmeg.org/blogs/code/2008/12/26/microsoft-lifecam-vx-3000-overview/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 19:29:20 +0000</pubDate>
		<dc:creator>dtjohnso</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[microsoft lifecam vx-3000]]></category>

		<guid isPermaLink="false">http://duncanandmeg.org/blogs/code/?p=44</guid>
		<description><![CDATA[This Christmas, my mother got the Microsoft LifeCam VX-3000 2 pack so that we can video chat with her when we&#8217;re at our home. Although the camera is certainly not a high-end webcam, it is enough for basic video chat needs. I won&#8217;t write a comprehensive review here, my purpose is just to clarify a [...]]]></description>
			<content:encoded><![CDATA[<p>This Christmas, my mother got the <a href="http://www.amazon.com/Microsoft-68A-00013-LifeCam-VX-3000-Pack/dp/B000NBAIZ8/ref=pd_bbs_sr_2?ie=UTF8&amp;s=electronics&amp;qid=1230320979&amp;sr=8-2" class="liexternal">Microsoft LifeCam VX-3000</a> 2 pack so that we can video chat with her when we&#8217;re at our home. Although the camera is certainly not a high-end webcam, it is enough for basic video chat needs. I won&#8217;t write a comprehensive review here, my purpose is just to clarify a few things that I&#8217;ve learned about the camera and then document how I set it up on my mom&#8217;s computer so others can properly configure things if anything later goes awry. For a helpful review of the VX-6000 (which appears to be the same camera except for a wide-angle lens and probably a few other perks), see <a href="http://www.geekzone.co.nz/content.asp?contentid=6721" class="liexternal">this review from a guy in New Zealand</a>.</p>
<p>The camera itself was fairly easy to install, and the proprietary Microsoft software works pretty well (although it&#8217;s a little too resource-intensive for my taste). You don&#8217;t have to install Windows Live Messenger to use the camera, but you will need it or Skype in order to make calls with the camera.<span id="more-44"></span></p>
<h3>Compatibility issues</h3>
<p>The camera appears to be <strong>incompatible with Windows XP Media Center and Vista 64-bit edition</strong>. I am not aware if Microsoft has updated the driver to solve this issue at this point, but this seems to be an issue from what I can tell reading online reviews and user forums.</p>
<p>Compatibility with Skype and Google Video Chat is mixed. The <strong>camera works with Skype</strong> basically &#8220;out of the box,&#8221; but at this point <strong>it does not work with Google Video Chat</strong> at all. Maybe a Google engineer will fix this sometime, but for now the testing window in my Gmail settings shows a black screen and the camera never turns on.</p>
<p>Although the camera works fine with Skype, getting the &#8220;Live Call&#8221; button on top to work with Skype requires a fairly simple hack. Since my family will make most of their video calls using Skype and not Windows Live Messenger, <span style="text-decoration: line-through;">I&#8217;ll explain that in a future post</span> I&#8217;ve explained that in <a href="http://duncanandmeg.org/blogs/code/2008/12/26/microsoft-lifecam-vx-3000-installation-configuration/" class="liinternal">another post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://duncanandmeg.org/blogs/code/2008/12/26/microsoft-lifecam-vx-3000-overview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://duncanandmeg.org/blogs/code/2008/12/26/microsoft-lifecam-vx-3000-overview/</feedburner:origLink></item>
		<item>
		<title>Burning CDs and DVDs in Windows XP… without unusual punishment</title>
		<link>http://feedproxy.google.com/~r/DJCode/~3/YkqCiKHgu1U/</link>
		<comments>http://duncanandmeg.org/blogs/code/2008/07/26/burning-cds-and-dvds-in-windows-xp-without-unusual-punishment/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 19:10:40 +0000</pubDate>
		<dc:creator>dtjohnso</dc:creator>
				<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://duncanandmeg.org/blogs/code/?p=27</guid>
		<description><![CDATA[Someday, burning optical media like CDs and DVDs may be a fully supported operating system feature. Until then, Windows users have to use burning software packages that unfortunately tend to bundle complexity and cost with a lot of frustration. Windows XP does support minimal burn operations when blank CDs and DVDs are opened as &#8220;writable&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Someday, burning optical media like CDs and DVDs may be a fully supported operating system feature. Until then, Windows users have to use burning software packages that unfortunately tend to bundle complexity and cost with a lot of frustration. Windows XP does support minimal burn operations when blank CDs and DVDs are opened as &#8220;writable&#8221; windows in My Computer, but this is not enough for creating anything beyond basic data disks.</p>
<p>I have used commercial burn software packages (like Nero and Roxio) before, but I chose <strong>not</strong> to use these packages again for a few recent projects. Here&#8217;s why:</p>
<ol>
<li>For a home user who rarely (read, almost never) needs to burn media anyway, it is difficult to justify the cost of either package.</li>
<li>Both Nero and Roxio bundle a lot of useless junkware into their packages (perhaps partially to justify their pricetag) and all I need is basic burn functionality.</li>
<li>Removing remnants of an expired &#8220;trial&#8221; version of either is not a task I relish. I&#8217;ve found (and Wikipedia concurs<sup><a href="http://duncanandmeg.org/blogs/code/2008/07/26/burning-cds-and-dvds-in-windows-xp-without-unusual-punishment/#footnote_0_27" id="identifier_0_27" class="footnote-link footnote-identifier-link" title="Wikipedia&amp;#8217;s article on Roxio&amp;#8217;s &amp;#8220;Easy Media Creator&amp;#8221; states &amp;#8220;Once installed, Easy Media Creator is difficult to uninstall. See the Roxio Community Forum, containing over 5000 posts concerning this topic. Roxio&amp;#8217;s official six-step uninstall process, which includes registry edits, is available at &amp;#8230;.&amp;#8221; ">1</a></sup>) that even licensed copies of these programs are hard to remove.</li>
</ol>
<p>With this in mind, I set out to find open source or freeware burn software without needless frills. I was looking for actively developed projects which might continue to be useful in the future. Two programs which do just that are <strong>InfraRecorder</strong> and <strong>ImgBurn</strong>.</p>
<p><a href="http://infrarecorder.sourceforge.net/" class="liexternal">InfraRecorder</a> is an open-source project, and it supports creating various data and audio CDs and DVDs (at this writing, it is in version 0.45). It does not yet support the creation of video DVDs, but it has a fairly simple interface, and enough basic documentation to help most users. I used it to burn a a large collection of MP3 files to a DVD without any problems.</p>
<p><a href="http://www.imgburn.com/" class="liexternal">ImgBurn</a> is freeware, and supports data, audio, and video for CDs, DVDs, HD-DVDs, and  Blu-ray (at this writing, it is in version 2.4.2.0). The interface is very clean and operation is straightforward. I probably like this program better than InfraRecorder because its basic approach appeals to me.</p>
<p>Rather than modeling all its operations like other burning software which combine high-level tasks like &#8220;Copy disk&#8221; or &#8220;Burn data disk&#8221; with lower-level processes such as creating a disk image, ImgBurn does everything from a low-level perspective. If you want to copy a disk, you first run the process to create an image file of the original disk, and then you insert a blank disk and burn the image file into the new disk. Although this approach may seem more technical to a new user than a higher-level approach, this approach is so simple (and the tutorials so straightforward) that when I first used it I feared that I was missing some detail simply because it seemed <em>too easy</em> to be true.</p>
<p>Amazingly, with all this simplicity, it really does support a high degree of customization for advanced users. The complexity is accessible, but you don&#8217;t have to deal with it unless you seek it out.</p>
<p>I&#8217;m glad I finally put some effort into finding burn software for future projects. Both of these are good programs that don&#8217;t annoy me in any of the ways the commercial packages did, and hopefully they&#8217;ll still be useful as technology and media standards progress. At least for now, these two will probably remain my burn packages of choice.</p>
<p class="footnotes">NOTES:</p><ol class="footnotes"><li id="footnote_0_27" class="footnote">Wikipedia&#8217;s <a href="http://en.wikipedia.org/wiki/Easy_Media_Creator" rel="nofollow" class="liwikipedia">article on Roxio&#8217;s &#8220;Easy Media Creator&#8221;</a> states <em>&#8220;Once installed, Easy Media Creator is difficult to uninstall. See the Roxio Community Forum, containing over 5000 posts concerning this topic. Roxio&#8217;s official six-step uninstall process, which includes registry edits, is available at &#8230;.&#8221;</em> </li></ol>]]></content:encoded>
			<wfw:commentRss>http://duncanandmeg.org/blogs/code/2008/07/26/burning-cds-and-dvds-in-windows-xp-without-unusual-punishment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://duncanandmeg.org/blogs/code/2008/07/26/burning-cds-and-dvds-in-windows-xp-without-unusual-punishment/</feedburner:origLink></item>
		<item>
		<title>Clean pastes with Excel VBA</title>
		<link>http://feedproxy.google.com/~r/DJCode/~3/TtJHe8kDUEo/</link>
		<comments>http://duncanandmeg.org/blogs/code/2007/12/14/clean-pastes-with-excel-vba/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 16:50:31 +0000</pubDate>
		<dc:creator>dtjohnso</dc:creator>
				<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://duncanandmeg.org/blogs/code/2007/12/14/clean-pastes-with-excel-vba/</guid>
		<description><![CDATA[I&#8217;ve talked about some of the Excel VBA I&#8217;ve done before, and here&#8217;s a new thing I learned today. Problem One part of my application selects a range from one worksheet in the spreadsheet and pastes it onto another. Originally, the code I used looked like this: destinationWorksheet.Range("A2").Select ActiveSheet.Paste&#60;/pre&#62; There is one problem I was [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve talked about <a href="/blogs/code/2007/09/13/fixing-memory-leaks-in-excel-vba-we-hope/" class="liinternal">some of the Excel VBA I&#8217;ve done</a> before, and here&#8217;s a new thing I learned today.<br />
<h3>Problem</h3>
<p>One part of my application selects a range from one worksheet in the spreadsheet and pastes it onto another. Originally, the code I used looked like this:</p>
<pre><code class=\'prettyprint\'  class="prettyprint">destinationWorksheet.Range("A2").Select
ActiveSheet.Paste&lt;/pre&gt;</code>

There is one problem I was unaware of. Every time the .Paste operation executed, it added a new "Named Range" to the ActiveSheet. I only realized this when snooping around in the Properties for the Excel file, where I found (to much dismay) 840 different "Named Ranges" referring to data long since thrown away! An older version of my application, which used this unspecified Paste operation much more frequently, had even more of these attached to numbers of other worksheets.<span id="more-23"></span>
<h3>Solution</h3>

The first thing I looked into was the properties of the .Paste method itself. Turns out there are two of them, "Destination" and "Link," and they are more or less mutually exclusive. The Excel VBA Help provides good explanation of that which I won't reproduce here.

The reason my old call for an unparameterized .Paste worked was that it simply used the current selection as the "Destination" property. This is explained from this portion of the Help document:
<blockquote>
<strong><em>Destination</em></strong> Optional <strong>Variant</strong>. ... If this argument is omitted, the current selection is used.</blockquote>

I had assumed that this parameter was irrelevant. The increase in these weird "Named Ranges" made me suspicious.

I modified my .Paste call this way to see if it would make a difference:
<pre><code class=\'prettyprint\'  class="prettyprint">ActiveSheet.Paste Destination:=ActiveCell</code></pre>
<p>Adding a parameter that specifies the default parameter anyway isn't a pretty fix, would it work? After executing a few calls to the .Paste statement in question, I was shocked! It <em>did</em> make a difference! No more "Named Ranges" were being appended to the ActiveSheet.<br />
<h3>Cleanup</h3>
<p>Wonderful, now I had 840 "Named Ranges" stuck in my file for no reason, referring to data long since wiped off the sheet. Some quick Help file searching taught me some things.</p>
<p>Each Worksheet object in a Workbook contains a collection of Name objects called Names. The Name objects in this collection are the "Named Ranges" in question. With some quick 'n dirty coding, I wiped them all out. Solution is below:</p>
<pre><code class=\'prettyprint\'  class="prettyprint">Private Sub NameDR4ng3z()
    ThisWorkbook.Worksheets("destinationWorksheetName").Activate

    For Each myName In ActiveSheet.Names 'list '
        Debug.Print myName.Name
    Next myName

    For Each myName In ActiveSheet.Names 'delete '
        myName.Delete
    Next myName

    Debug.Print "Names deleted? We'll see"
    For Each myName In ActiveSheet.Names 'double-check '
        Debug.Print myName.Name
    Next myName
End Sub</code></pre>
<p>This worked. I'm happy.</p>
]]></content:encoded>
			<wfw:commentRss>http://duncanandmeg.org/blogs/code/2007/12/14/clean-pastes-with-excel-vba/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://duncanandmeg.org/blogs/code/2007/12/14/clean-pastes-with-excel-vba/</feedburner:origLink></item>
		<item>
		<title>Lazy list management</title>
		<link>http://feedproxy.google.com/~r/DJCode/~3/09bFfvXiyZI/</link>
		<comments>http://duncanandmeg.org/blogs/code/2007/11/12/lazy-list-management/#comments</comments>
		<pubDate>Mon, 12 Nov 2007 21:28:09 +0000</pubDate>
		<dc:creator>dtjohnso</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://duncanandmeg.org/blogs/code/2007/11/12/lazy-list-management/</guid>
		<description><![CDATA[I use a couple awk scripts to manage a list of students who come to church with me every week. When a student tells me he will be coming on Sunday, I put an asterisk (*) in front of his name in a static text file with everyone&#8217;s names. If they tell me they won&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I use a couple awk scripts to manage a list of students who come to church with me every week. When a student tells me he will be coming on Sunday, I put an asterisk (*) in front of his name in a static text file with everyone&#8217;s names. If they tell me they won&#8217;t be coming, I put a minus sign (-) in front of their name so I remember that they said so. If for some reason I&#8217;m not sure, I put a question mark (?).</p>
<p>My main script spits out a list of all the students who are coming (i.e., have an asterisk). There&#8217;s no genius to it, I&#8217;m just logging it here for reference.</p>
<p>I also have another script that wipes all the attendance marks out of the main list file.<span id="more-10"></span></p>
<h2>Files</h2>
<p>All files are available here:
<ul>
<li>
<a href="http://duncanandmeg.org/blogs/code/wp-content/uploads/2007/11/studentlist.zip" title='List management files' class="lizip">List management files</a></li>
</ul>
<p>Source is posted below without comment since it&#8217;s basically self-explanatory.</p>
<h3>StudentList.bash</h3>
<pre><code class=\'prettyprint\'  class="prettyprint">awk 'substr($1,0,1) == "*" { print substr($0,2,length($0)) } ' students.txt &gt; studentsComing.txt
cat studentsComing.txt</code></pre>
<h3>WipeStudentList.bash</h3>
<pre><code class=\'prettyprint\'  class="prettyprint">awk -f Wipe.awk &lt;students.txt &gt;temp
cat temp &gt;students.txt
rm temp
./studentlist.bash</code></pre>
<h3>Wipe.awk</h3>
<pre><code class=\'prettyprint\'  class="prettyprint">{if ( substr($1,0,1) == "*" || substr($1,0,1) == "-" || substr($1,0,1) == "?" )
  { print substr($0,2,length($0))  }
 else
  { print $0 }
}</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://duncanandmeg.org/blogs/code/2007/11/12/lazy-list-management/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://duncanandmeg.org/blogs/code/2007/11/12/lazy-list-management/</feedburner:origLink></item>
		<item>
		<title>Producing valid RSS from my XSL Transform</title>
		<link>http://feedproxy.google.com/~r/DJCode/~3/8Ik_pTM6v4o/</link>
		<comments>http://duncanandmeg.org/blogs/code/2007/10/11/producing-valid-rss-from-my-xsl-transform/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 21:15:37 +0000</pubDate>
		<dc:creator>dtjohnso</dc:creator>
				<category><![CDATA[XML & XSL]]></category>

		<guid isPermaLink="false">http://duncanandmeg.org/blogs/code/2007/10/11/producing-valid-rss-from-my-xsl-transform/</guid>
		<description><![CDATA[In a previous post, I showed the XSL transform I designed to transform a simple XML file I use into &#8220;(almost) valid RSS.&#8221; I called it (almost) valid because of one problem, which I address here. The problem reviewed My original XSL assigned an arbitrary ID to each entry in the news file based on [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="/blogs/code/2007/08/13/rendering-xml-as-valid-rss-with-xslt/" class="liinternal">a previous post</a>, I showed the XSL transform I designed to transform a simple XML file I use into &#8220;(almost) valid RSS.&#8221; I called it (almost) valid because of one problem, which I address here.</p>
<h2>The problem reviewed</h2>
<p>My original XSL assigned an arbitrary ID to each entry in the news file based on its order in the list. What this meant was that the first item received the integer 1 for an ID, the second 2, the third 3, etc. Here it is:</p>
<pre><code class=\'prettyprint\'  class="prettyprint">&amp;lt;!--old method, produces invalid link &amp; guid--&amp;gt;
&amp;lt;link&amp;gt;&amp;lt;xsl:text&amp;gt;http://www.duncanandmeg.org/news.php#&amp;lt;/xsl:text&amp;gt;
  &amp;lt;xsl:value-of select="position()" /&amp;gt;&amp;lt;/link&amp;gt;
&amp;lt;guid&amp;gt;&amp;lt;xsl:text&amp;gt;http://www.duncanandmeg.org/news.php#&amp;lt;/xsl:text&amp;gt;
  &amp;lt;xsl:value-of select="position()" /&amp;gt;&amp;lt;/guid&amp;gt;</code></pre>
<p>This was fine for my original purposes, but since this hardly represented a unique &#038; permanent identifier for each post, it caused some problems when echoed into the RSS &lt;guid&gt; and &lt;link&gt; elements. The significance of the &lt;guid&gt; element in particular is eliminated with such an approach. Every time I added an item to the list (see the previous post for an explanation of my schema), it would be assigned the ID of 1, and the older posts would be assigned the ID numbers 2, 3, 4, 5 etc.</p>
<p>This meant that most RSS aggregators would not detect that a new post had appeared and would not update accordingly.<br />
<span id="more-8"></span></p>
<h2>Choosing a unique ID schema</h2>
<p>Since I could no longer use my simple numbering scheme based on position in the original XML file, I had to come up with some other identifier. I learned about the <a href="http://www.taguri.org/" class="liexternal">Tag URI algorithm</a>, but decided that it was more complex than I really needed for this application, and the scheme of my original XML file didn&#8217;t lend itself to producing these anyway.</p>
<p>Since I don&#8217;t update the entries in this file frequently, I invented a simple method that produces relatively unique identifiers based on each entry&#8217;s data. All my new ID&#8217;s consist of two elements based on the data in my XML file:</p>
<ol>
<li>The text from the entry&#8217;s title preceding the first space (&#8221; &#8220;) character<br/><i>(If the entry consists of only one word, this element will not appear. This is a weakness that would be more important if updates were frequent)</i></li>
<li>The date of the entry encoded in the format <i>mm-dd-yy</i></li>
</ol>
<p>Once I settled on my scheme, producing it in XSL turned out to be fairly simple.</p>
<h2>XSL transform</h2>
<p>I&#8217;m including only the portion of the XSL tranform that deals with the entry &lt;link&gt; and &lt;guid&gt; here. The rest of it is in <a href="/blogs/code/2007/08/13/rendering-xml-as-valid-rss-with-xslt/" class="liinternal">the previous post</a>.</p>
<pre><code class=\'prettyprint\'  class="prettyprint">&amp;lt;item&amp;gt;
  &amp;lt;title&amp;gt;&amp;lt;xsl:value-of select="headline" /&amp;gt;&amp;lt;/title&amp;gt;

  &amp;lt;!--unique id created and stored in XSL variable--&amp;gt;
  &amp;lt;xsl:variable name="bookmark"&amp;gt;

    &amp;lt;!--find word before first space--&amp;gt;
    &amp;lt;xsl:value-of select="substring-before (headline, ' ')" /&amp;gt;
    &amp;lt;!--produce date in format mm-dd-yy--&amp;gt;
    &amp;lt;xsl:value-of select="translate (date, '/', '-')" /&amp;gt;

  &amp;lt;/xsl:variable&amp;gt;

  &amp;lt;!--variable placed in link and guid elements--&amp;gt;
  &amp;lt;link&amp;gt;&amp;lt;xsl:text&amp;gt;http://www.duncanandmeg.org/news.php#&amp;lt;/xsl:text&amp;gt;
    &amp;lt;xsl:value-of select="$bookmark" /&amp;gt;&amp;lt;/link&amp;gt;
  &amp;lt;guid&amp;gt;&amp;lt;xsl:text&amp;gt;http://www.duncanandmeg.org/news.php#&amp;lt;/xsl:text&amp;gt;
    &amp;lt;xsl:value-of select="$bookmark" /&amp;gt;&amp;lt;/guid&amp;gt;

  &amp;lt;!-- continue with transform, see original post --&amp;gt;

&amp;lt;/item&amp;gt;</code></pre>
<p>With a reasonably unique guid, most RSS readers properly update now when I post new items.</p>
]]></content:encoded>
			<wfw:commentRss>http://duncanandmeg.org/blogs/code/2007/10/11/producing-valid-rss-from-my-xsl-transform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://duncanandmeg.org/blogs/code/2007/10/11/producing-valid-rss-from-my-xsl-transform/</feedburner:origLink></item>
		<item>
		<title>Fixing memory leaks in Excel VBA… (we hope)</title>
		<link>http://feedproxy.google.com/~r/DJCode/~3/2T2W62qKDxg/</link>
		<comments>http://duncanandmeg.org/blogs/code/2007/09/13/fixing-memory-leaks-in-excel-vba-we-hope/#comments</comments>
		<pubDate>Fri, 14 Sep 2007 02:05:52 +0000</pubDate>
		<dc:creator>dtjohnso</dc:creator>
				<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://duncanandmeg.org/blogs/code/2007/09/13/fixing-memory-leaks-in-excel-vba-we-hope/</guid>
		<description><![CDATA[One project I constantly return to is an application I built in Excel VBA that does a lot of different things. One specific problem remains unsolved with this application, so I&#8217;ve decided to throw it out here and see if any gurus have an answer. Basically, as a result of some Excel memory leaks beyond [...]]]></description>
			<content:encoded><![CDATA[<p>One project I constantly return to is an application I built in Excel VBA that does a lot of different things. One specific problem remains unsolved with this application, so I&#8217;ve decided to throw it out here and see if any gurus have an answer.</p>
<p>Basically, as a result of some Excel memory leaks beyond my control (I can&#8217;t install recommended hotfixes on the computers where this application is used, and need to be able to handle the issue with/without hotfixes anyway), when I shut down Excel it typically remains stuck in memory (and visible under &#8220;Processes&#8221; in &#8220;Task Manager&#8221;) even though it looks like it is gone to the user.<br />
<h3>Paranoia</h3>
<p>I realize that many would argue that since this bug is Microsoft&#8217;s problem and not mine, that I shouldn&#8217;t trouble with addressing it. However, since this application I&#8217;ve built is something that gets used frequently (but not constantly) throughout the day, I can imagine this becoming a problem (or at least wasting resources) at some point.</p>
<p>Another rejoinder to this charge is quite simple: I&#8217;ve actually ignored this issue for about a year now already, and am only revisiting it because I&#8217;ve learned some things about VBA that enable me to possibly defeat it. If I didn&#8217;t have any hope of fixing this, I wouldn&#8217;t try.<span id="more-7"></span><br />
<h3>Problem (in more depth)</h3>
<p>Here is what I know about why one of my memory leak problems exists (this article won&#8217;t deal with all my memory leak issues in the application, since I still haven&#8217;t made any headway on the others). I may not have quite the right diagnosis here, but tests to this point suggest I might be on the right track.</p>
<p>The main worksheet in my application includes numerous embedded control buttons that marshall up various cool features I&#8217;ve built for this VBA app. Unfortunately, it appears that <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;238570" class="liexternal">embedding any sort of control (as far as I can tell) on a worksheet can cause Excel to commit memory leaks</a>.</p>
<p>Before going further, a few notes about the KB article I just mentioned:</p>
<ol>
<li>This article refers to an issue with Excel 97.</li>
<li>I&#8217;m not sure that worksheet buttons are considered ActiveX or OCX controls</li>
</ol>
<p>The problem here is simple: I did some research on this a year ago when I first discovered the issue, and didn&#8217;t keep track of the KB article I found that suggested the problem with embedded buttons. I remember reading something like that then, but can&#8217;t find it now. The only reason I think this might actually be the source of the problem is because my hacked solution seems to prevent the memory leak in question.<br />
<h3>Ugly solution</h3>
<p>I learned that it is possible in Excel VBA to <a href="http://support.microsoft.com/kb/141563" class="liexternal">write an Auto_Close sub to override default behavior when closing a spreadsheet</a>. <strike>(If I ever track down the documentation that tipped me off to this, I&#8217;ll link to it here.)</strike></p>
<p>This suggested that I might be able to do something on the file&#8217;s close event that might at least catch and destroy the source of the memory leak before the Excel app slipped out of my control until an inevitable Ctrl+Alt+Del. Here&#8217;s the ugly, scary code:</p>
<pre><code class=\'prettyprint\'  class="prettyprint">Sub Auto_Close()
    'Deletes the spreadsheet with the embedded buttons '
    Application.DisplayAlerts = False
    ThisWorkbook.Worksheets("Sheet1").Delete

    'Prevents prompt to save changes, so that workbook closes without saving '
    'This prevents the sheet from being really deleted '
    ThisWorkbook.Saved = True
End Sub</code></pre>
<h3>Concerns</h3>
<p>After this function fires, Excel closes as normal, without saving the file. Since this fires whenever the user closes the file, it seems safe enough to do this, but you can&#8217;t help being a little bit frightened with an approach like this.<br />
<h3>Tests and reasoning</h3>
<p>I think this works. Before, when I would exit Excel, an instance of EXCEL.EXE would remain in my &#8220;Process&#8221; list in Task Manager until I manually terminated it, logged out, or rebooted. Now when I exit Excel, it disappears from the list as normal (unless I&#8217;ve used some other parts of the application which induce the other memory leak problems I&#8217;m not discussing here). It appears that the embedded button memory leak problem is bypassed (I really hesitate to say &#8220;solved&#8221;).<br />
<h3>Suggestions?</h3>
<p>If you have handled this problem before, have more information, or know how a better (and saner) way to fix this, please post a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://duncanandmeg.org/blogs/code/2007/09/13/fixing-memory-leaks-in-excel-vba-we-hope/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://duncanandmeg.org/blogs/code/2007/09/13/fixing-memory-leaks-in-excel-vba-we-hope/</feedburner:origLink></item>
	</channel>
</rss>

