<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Murray Hopkins' Weblog</title>
	<atom:link href="http://murrayhopkins.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://murrayhopkins.wordpress.com</link>
	<description>Mostly programming stuff - but who knows what might happen ??</description>
	<lastBuildDate>Thu, 22 Sep 2011 22:08:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='murrayhopkins.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Murray Hopkins' Weblog</title>
		<link>http://murrayhopkins.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://murrayhopkins.wordpress.com/osd.xml" title="Murray Hopkins&#039; Weblog" />
	<atom:link rel='hub' href='http://murrayhopkins.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Outlook 2007 &#8211; take care when switching from Exchange Server!</title>
		<link>http://murrayhopkins.wordpress.com/2011/08/22/outlook-2007-take-care-when-switching-from-exchange-server/</link>
		<comments>http://murrayhopkins.wordpress.com/2011/08/22/outlook-2007-take-care-when-switching-from-exchange-server/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 09:38:47 +0000</pubDate>
		<dc:creator>Murray Hopkins</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://murrayhopkins.wordpress.com/?p=139</guid>
		<description><![CDATA[Our company recently switched it’s email server from Exchange Server. Not thinking, I deleted the Exchange item: Tools / Account Settings / Email / Remove. Not a good move! Normal Outlook data files are PST files (e.g. outlook.pst). Exchange Server files are .OST files. Microsoft intentionally do not provide a way to convert an OST [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=139&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Our company recently switched it’s email server from Exchange Server. Not thinking, I deleted the Exchange item: Tools / Account Settings / Email / Remove. Not a good move!</p>
<p>Normal Outlook data files are PST files (e.g. outlook.pst). Exchange Server files are .OST files. Microsoft intentionally do not provide a way to convert an OST file to a PST file! Oh shit! There are commercial solutions and other solutions that may or may not work to convert the file.</p>
<p>After the panic subsided, I realised that I still had the company&#8217;s Exchange Server setup on my old laptop&#8217;s Outlook. So, I copied the OST file across to that laptop (so I had the emails that were present at the time I stopped using Exchange), fired up Outlook which told me the server was AWOL (which didnt matter), all my email and folders were there! Phew.</p>
<p>I then Archived ALL the folders (File / Archive, etc which copies the data to a PST file &#8211; e.g. archive.pst). I then copied the archive.pst file back to my new laptop, started Outlook and voila, all the old email was available.</p>
<p>So, the moral is, if you are switching from Exchange and not migrating your old email to a new mail system, ARCHIVE all your old email BEFORE you disconnect the Exchange data file from Outlook!</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/murrayhopkins.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/murrayhopkins.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/murrayhopkins.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/murrayhopkins.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/murrayhopkins.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/murrayhopkins.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/murrayhopkins.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/murrayhopkins.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/murrayhopkins.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/murrayhopkins.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/murrayhopkins.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/murrayhopkins.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/murrayhopkins.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/murrayhopkins.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=139&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://murrayhopkins.wordpress.com/2011/08/22/outlook-2007-take-care-when-switching-from-exchange-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bab3d6eac3bdc2e530db285f993b1f0d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">murrah</media:title>
		</media:content>
	</item>
		<item>
		<title>Solved: Outlook 2007 &#8211; email stuck in Outbox after switching from Exchange Server to Gmail IMAP &#8211; error 0&#215;80040201</title>
		<link>http://murrayhopkins.wordpress.com/2011/08/22/solved-outlook-2007-email-stuck-in-outbox-after-switching-from-exchange-server-to-gmail-imap/</link>
		<comments>http://murrayhopkins.wordpress.com/2011/08/22/solved-outlook-2007-email-stuck-in-outbox-after-switching-from-exchange-server-to-gmail-imap/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 09:22:20 +0000</pubDate>
		<dc:creator>Murray Hopkins</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://murrayhopkins.wordpress.com/?p=134</guid>
		<description><![CDATA[This took a long time to work out. As usual, someone had walked the path before me but it took a while to find that solution amongst all the false leads (in my case). Our company had recently switched it&#8217;s email from Exchange Server to Gmail. (Yes, they are aware of the security issues. Anyway [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=134&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This took a long time to work out. As usual, someone had walked the path before me but it took a while to find that solution amongst all the false leads (in my case).</p>
<p>Our company had recently switched it&#8217;s email from Exchange Server to Gmail. (Yes, they are aware of the security issues. Anyway &#8230;). Not liking the GMail interface etc I wanted to continue using Outlook for my mail client and using GMail&#8217;s IMAP to do that. After setting that up (lots of posts on the net on how to do that), I noticed the following problem.</p>
<p><span style="color:#ff0000;">Important note: See <a title="this post" href="http://murrayhopkins.wordpress.com/2011/08/22/outlook-2007-take-care-when-switching-from-exchange-server/" target="_blank">this post</a> BEFORE you delete your old Outlook Exchange file. If you do it the wrong way you will lose all your email!</span></p>
<p>The problem: When I created a new email to some of my contacts, or replied to an email from one of those same contacts, the email stayed in the Outbox of my default PST file. Sometimes it threw the error 0&#215;80040201. Nothing I did would cause Outlook to send the email. Other email addresses worked fine! Very weird. Eventually I discovered the post below that explained that the problem was due to the Outlook.nk2 file that contains the data for the auto-complete functionality of Outlook. That file remembers whether the address is an Exchange Server address or an SMTP address. And guess what? All the addresses I had problems with had Exchange settings.</p>
<p>So, see the LAST item on this post: <a href="http://www.pcreview.co.uk/forums/getting-error-0x80040201-t1872774.html" target="_blank">http://www.pcreview.co.uk/forums/getting-error-0&#215;80040201-t1872774.html</a> which explains a couple of fixes.</p>
<p>Alternatively, download this: <a href="http://www.nirsoft.net/utils/outlook_nk2_edit.html" target="_blank">http://www.nirsoft.net/utils/outlook_nk2_edit.html</a> and delete all the email items with an account type of EX (as opposed to SMTP) and follow the instructions. You will then need to type the full email address the next time you send to that person and it will then remember the correct settings. Some addresses had both EX and SMTP entries so deleting the EX entries allowed the SMTP entries to correctly auto-correct.</p>
<p>I hope this saves someone the hours it took for me to find the solution.</p>
<p><span style="color:#ff0000;">NB: there is still a problem with Outlook that appears to be a bug.</span> To get the email to actually send, you must click Send/Receive / Send ALL. I haven&#8217;t found a way for it to send automatically but at least I can send email with a couple of extra button clicks!</p>
<p>Now, I wonder how well Thunderbird&#8217;s IMAP works?</p>
<p>Cheers,</p>
<p>Murray</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/murrayhopkins.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/murrayhopkins.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/murrayhopkins.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/murrayhopkins.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/murrayhopkins.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/murrayhopkins.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/murrayhopkins.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/murrayhopkins.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/murrayhopkins.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/murrayhopkins.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/murrayhopkins.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/murrayhopkins.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/murrayhopkins.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/murrayhopkins.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=134&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://murrayhopkins.wordpress.com/2011/08/22/solved-outlook-2007-email-stuck-in-outbox-after-switching-from-exchange-server-to-gmail-imap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bab3d6eac3bdc2e530db285f993b1f0d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">murrah</media:title>
		</media:content>
	</item>
		<item>
		<title>Using AlivePDF to print from AIR Javascript via ActionScript3 &#8211; part 1</title>
		<link>http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-1/</link>
		<comments>http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-1/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 22:01:35 +0000</pubDate>
		<dc:creator>Murray Hopkins</dc:creator>
				<category><![CDATA[Adobe AIR]]></category>

		<guid isPermaLink="false">http://murrayhopkins.wordpress.com/?p=89</guid>
		<description><![CDATA[See also Part 2 of this article. As has been blogged in many places, printing from AIR is very limited and problematic. It seemed to me that a way around the lack of printing support would be to have the ability to create PDF files client-side, as opposed to sending all the data to be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=89&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>See also <a title="http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-2/" href="http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-2/" target="_blank">Part 2</a> of this article.</p>
<p>As has been blogged in many places, printing from AIR is very limited and problematic. It seemed to me that a way around the lack of printing support would be to have the ability to create PDF files client-side, as opposed to sending all the data to be printed to the server then getting a PDF back again. Knowing that it was possible to invoke ActionScript classes from HTML/Javascript AIR apps, eg <a title="http://www.coldfusionjedi.com/index.cfm/2010/8/17/HTMLAdobe-AIR-Application-Diversion-Three--Add-ActionScript-to-your-HTML" href="http://www.coldfusionjedi.com/index.cfm/2010/8/17/HTMLAdobe-AIR-Application-Diversion-Three--Add-ActionScript-to-your-HTML" target="_blank"> this post by Ray Camden</a> and using that post as a start, I began exploring the possibilities.</p>
<p>This post covers what I found along the way. In summary:</p>
<ol>
<li>It <strong>is </strong>possible to create PDF files completely client-side from Javascript AIR apps via ActionsScript. A &#8220;proof of concept&#8221; is at the end of this post.</li>
<li>You can use the free Flex SDK to develop the SWF file you need to invoke the required ActionScript classes.</li>
<li>You can set up Eclipse to do that (ie you dont need FlexBuilder or be restricted to command line compiling)</li>
<li>There are lots of other AS libraries out there that can be used using the techniques discussed in this post.</li>
</ol>
<p>Until I started this process I had never really looked at ActionScript so the following is very much from the perspective of a newbie!</p>
<h2>Basic AS info</h2>
<p>First, read <a href="http://www.coldfusionjedi.com/index.cfm/2010/8/17/HTMLAdobe-AIR-Application-Diversion-Three--Add-ActionScript-to-your-HTML" target="_blank"> Ray&#8217;s post </a> as a starting point.</p>
<p>Download the <a title="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex4sdk" href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex4sdk" target="_blank">Flex 4 SDK from here</a>. Unzip it somewhere (in my case D:\flex_sdk_4.1).</p>
<p>The AS library you need in your AIR app is contained in a SWF file as you can see in Ray&#8217;s post.  There are 2 ways to compile your SWF file. As Ray says, the Adobe docs suggest using the acompc command line compiler, which outputs a SWC / Zip file that you can extract the SWF from. A simpler way is to use the amxmlc command line compiler instead which outputs directly to the SWF file. Both of these compilers are in the Flex SDK /bin folder.</p>
<p>Ray&#8217;s example assumes you are creating an AS package from scratch. What I wanted to do was to use an existing library and extend it. Before I discuss the command line compiler settings, I need to digress into talking about the libraries I found.</p>
<h2>AS PDF options</h2>
<p>I found two AS libraries that create PDF files client-side &#8211; <a title="http://alivepdf.bytearray.org/" href="http://alivepdf.bytearray.org/" target="_blank">AlivePDF</a> and <a title="http://www.sephiroth.it/weblog/archives/2010/02/purepdf_a_complete_actionscript_pdf_l.php" href="http://www.sephiroth.it/weblog/archives/2010/02/purepdf_a_complete_actionscript_pdf_l.php" target="_blank">purePDF</a>. The latter interested me particularly because it is a port of <a title="http://itextpdf.com/" href="http://itextpdf.com/" target="_blank">iText</a> java library which I was already familiar with. However, as discussed in my <a href="http://groups.google.com/group/purepdf-discuss/browse_thread/thread/fe855656ea9c2f26">forum post here</a>, I was unable to get purePDF to work  so I switched to AlivePDF which was more successful. It is highly likely that my problems with purePDF we of my own making. However I was unable to get any help to work out what, if anything, I was doing wrong.</p>
<h2>Extending an AS library</h2>
<p>The basic method is that you create a new AS package that imports the classes that you need from the library. The AS class library is in a SWC file (ie is compiled) and the Flex / AS compiler imports the classes that you need from that file.</p>
<p>So, the easiest way I found to do this (before I found out how to use Eclipse) is as follows. I include this info here to help explain the process.</p>
<p>What I did was to take the AS code from <a title="http://pradeek.blogspot.com/2009/05/alivepdf-tutorial-how-to-create-pdf.html" href="http://pradeek.blogspot.com/2009/05/alivepdf-tutorial-how-to-create-pdf.html" target="_blank">this example</a> and converted it into the following package.</p>
<p><pre class="brush: as3;">
package {
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;

    import org.alivepdf.pdf.PDF;
    import org.alivepdf.saving.Method;
    import org.alivepdf.fonts. * ;
    import org.alivepdf.pages.Page;
    import org.alivepdf.display.Display;
    import org.alivepdf.layout. * ;

    import mx.utils.UIDUtil;

    import flash.filesystem.FileStream;
    import flash.filesystem.File;
    import flash.filesystem.FileMode;

    import flash.utils.ByteArray;

    // You need to extend the Flex class Sprite for AIR to be able to run the code
    public class aliveDemo extends Sprite {
        private
        var pdf: PDF;
        private
        var file: File;

        // Removed the image to simplify the testing
        //[Embed( source=&quot;/assets/o-png24.png&quot;, mimeType=&quot;application/octet-stream&quot; )]
        //private var pngBytes:Class;
        public function aliveDemo() {}

        public function generate(): String {
            var pdf: PDF = new PDF(Orientation.PORTRAIT, Unit.MM, Size.A4);
            pdf.setDisplayMode(Display.FULL_PAGE, Layout.SINGLE_PAGE);

            var newPage: Page = new Page(Orientation.PORTRAIT, Unit.MM, Size.A4);
            pdf.addPage(newPage);

            // The following line turned out not to work as the API had changed since the original example was posted
            // pdf.setFont(FontFamily.ARIAL , Style.NORMAL, 12);
            // The correct way to do it now is:
            var myCoreFont: IFont = new CoreFont(FontFamily.HELVETICA);
            pdf.setFont(myCoreFont, 20);

            pdf.addText(&quot;This is a sample text&quot;, 5, 15);
            pdf.drawCircle(25, 35, 15);

            pdf.addPage();
            pdf.writeText(12, &quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\nPraesent vel lectus lorem. Phasellus convallis, tortor a venenatis mattis, erat mi euismod tellus, in fermentum sapien nibh sit amet urna. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent tellus libero, lacinia ac egestas eget, interdum quis purus. Donec ut nisl metus, sit amet viverra turpis. Mauris ultrices dapibus lacus non ultrices. Cras elementum luctus mauris, vitae eleifend diam accumsan ut. Aliquam erat volutpat. Suspendisse placerat nibh in libero tincidunt a elementum mi vehicula. Donec lobortis magna vel nibh mollis tempor. Maecenas et elit nunc. Nam non auctor orci. Aliquam vel velit vel mi adipiscing semper in ac orci. Vestibulum commodo sem eget tortor lobortis semper. Ut sit amet sapien non velit rutrum egestas sollicitudin in elit. Fusce laoreet leo a sem mattis iaculis&quot;);

            // Removed this image for testing
            // pdf.addImageStream( new pngBytes() as ByteArray );
            // Save to file
            var fs: FileStream = new FileStream();
            file = new File(&quot;C:/CFusionMX7/wwwroot/Sites/TestAS/aliveDemo.pdf&quot;); // Set your own path here!

            fs.open(file, FileMode.WRITE);
            var bytes: ByteArray = pdf.save(Method.LOCAL);
            fs.writeBytes(bytes);
            fs.close();

            return &quot;End of generate&quot;;
        }

    }
}
</pre></p>
<p>I saved this directly to the Flex SDK /bin folder as <code>AliveDemo.as</code> (remember I was in quick and dirty test mode at this stage).</p>
<p>Then, to compile it:</p>
<ol>
<li>Create a folder in the /bin folder called <code>alivepdflib</code></li>
<li>Download the <a title="http://code.google.com/p/alivepdf/downloads/list" href="http://code.google.com/p/alivepdf/downloads/list">AlivePDF package</a> (AlivePDF 0.1.5 RC.zip) and extract it</li>
<li>Copy the AlivePDF.swc file from \AlivePDF 0.1.5 RC\Sources\bin into the <code>alivepdflib</code> folder created in step 1</li>
<li>From the command line in the Flex SDK /bin folder, execute <code>amxmlc -library-path+=alivepdflib aliveDemo.as</code></li>
</ol>
<p>What that does is to create a file called <code>aliveDemo.swf</code> in the \bin folder by linking whatever SWC files are found in the <code>alivepdflib</code> folder and importing those classes into my <code>aliveDemo.as</code> class.</p>
<p>Then, I created an AIR app in Ecplise and set the HTML as follows:</p>
<p><pre class="brush: jscript;">
&lt;html&gt;
    
    &lt;head&gt;
        &lt;title&gt;
            Test alivePDF
        &lt;/title&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;lib/air/AIRAliases.js&quot;&gt;&lt;/script&gt;
        &lt;!--- Drop the created SWF file in the /lib folder ---&gt;
        &lt;script src=&quot;lib/aliveDemo.swf&quot; type=&quot;application/x-shockwave-flash&quot;&gt;&lt;/script&gt;
        &lt;script&gt;
            // Instantiate the class
            var ASlib = new window.runtime.aliveDemo();
            // Call the generate method
            var result = ASlib.generate();
            // Display the message to show we completed OK
            air.trace(result)
            // The aliveDemo.pdf will be located where ever you saved it to in aliveDemo.as
        &lt;/script&gt;
    &lt;/head&gt;
    
    &lt;body&gt;
    &lt;/body&gt;

&lt;/html&gt;
</pre></p>
<p>I copied the <code>aliveDemo.swf</code> file into the /bin folder in my AIR app, then ran the app and hey presto! a pdf file!!</p>
<p>The next step was to make a javascript wrapper so I could actually create the PDF on demand. Before that though, I set up the Flex SDK in Eclipse.</p>
<h2>Setting up Flex 4 SDK in Eclipse</h2>
<p>Using this <a title="http://www.seanhsmith.com/2010/03/29/flex-for-free-setting-up-the-flex-4-sdk-with-eclipse-ide/" href="http://www.seanhsmith.com/2010/03/29/flex-for-free-setting-up-the-flex-4-sdk-with-eclipse-ide/" target="_blank">very useful post</a> as a basis, I made the following adjustments for the AIR environment:</p>
<ol>
<li>I did not bother creating the application.mxml file because the amxmlc command line compiler is actually a batch file that appends the correct xml data for compiling for AIR.</li>
<li>In the Eclipse builder configuration section, I used the following settings instead of the ones in the post:
<ol>
<li>Location= D:\flex_sdk_4.1\bin\amxmlc.bat (ie use YOUR path to the Flex SDK)</li>
<li>Working directory=${workspace_loc:/JSPDF} (browse to YOUR project folder, mine was called JSPDF)</li>
<li>Arguments= -library-path+=libs src/alivePDFWrapper.as -output C:/CFusionMX7/wwwroot/Sites/TestAS/lib/alivePDFWrapper.swf (set the path of the -output parameter to YOUR AIR project so that the SWF file is saved there for you)</li>
<li>I didnt set the suggested Build Options check boxes since I didnt want the compiler to run automatically. To build, you highlight the .as file you need to compile and use CTRL+B (in windows)</li>
</ol>
</li>
<li>Copy the AlivePDF.swc file into the /libs folder in your project</li>
<li>Copy the alivePDFWrapper.as file from Part 2 of this post to the /src folder of your project</li>
</ol>
<h2>The javascript wrapper</h2>
<p>While it is possible to call the ActionScript methods directly, class instatiation gets tricky because the AS classes are &#8220;data types&#8221; that Javascript cant know about. My solution is to create an AS class that acts as a wrapper exposing the required methods but using data types that Javascript can handle. Since this wrapper and it&#8217;s associated JS class is the &#8220;solution&#8221; (well, so far anyway) to my problem of creating PDF files from Javascript, I have posted this section separately for those who dont care about all the above background. See <a title="http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-2/" href="http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-2/" target="_blank">Part 2</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/murrayhopkins.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/murrayhopkins.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/murrayhopkins.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/murrayhopkins.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/murrayhopkins.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/murrayhopkins.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/murrayhopkins.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/murrayhopkins.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/murrayhopkins.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/murrayhopkins.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/murrayhopkins.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/murrayhopkins.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/murrayhopkins.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/murrayhopkins.wordpress.com/89/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=89&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bab3d6eac3bdc2e530db285f993b1f0d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">murrah</media:title>
		</media:content>
	</item>
		<item>
		<title>Using AlivePDF to print from AIR Javascript via ActionScript3 &#8211; part 2</title>
		<link>http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-2/</link>
		<comments>http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-2/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 22:01:10 +0000</pubDate>
		<dc:creator>Murray Hopkins</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://murrayhopkins.wordpress.com/?p=108</guid>
		<description><![CDATA[For the background to this post, and how to use the following code, see Part 1 In this section I will describe the &#8220;solution&#8221; I found to the problem of the lack of adequate printing capability in AIR apps. My solution is to use ActionScript to create a PDF on the fly on the client-side. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=108&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For the background to this post, and how to use the following code, see <a title="http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-1/" href="http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-1/">Part 1</a></p>
<p>In this section I will describe the &#8220;solution&#8221; I found to the problem of the lack of adequate printing capability in AIR apps. My solution is to use ActionScript to create a PDF on the fly on the client-side. In this case, I am creating it from Javascript since I develop HTML/Javascript apps (using the EXTJS library). This solution does NOT require EXTJS or any other JS library.</p>
<blockquote><p>I found two AS libraries that create PDF files client-side &#8211; <a title="http://alivepdf.bytearray.org/" href="http://alivepdf.bytearray.org/">AlivePDF</a> and <a title="http://www.sephiroth.it/weblog/archives/2010/02/purepdf_a_complete_actionscript_pdf_l.php" href="http://www.sephiroth.it/weblog/archives/2010/02/purepdf_a_complete_actionscript_pdf_l.php">purePDF</a>. The latter interested me particularly becuase it is a port of <a title="http://itextpdf.com/" href="http://itextpdf.com/">iText</a> java library which I was already familiar with. However, as discussed in my <a href="http://groups.google.com/group/purepdf-discuss/browse_thread/thread/fe855656ea9c2f26">forum post here</a>,  I was unable to get purePDF to work  so I switched to AlivePDF which  was more successful. It is highly likely that my problems with purePDF  we of my own making. However I was unable to get any help to work out  what, if anything, I was doing wrong.</p></blockquote>
<p>Now, this is really the start of the solution and very much a work in progress. I would value feedback about the overall approach and architecture I am proposing. Since I really wanted to use purePDF instead of AlivePDF, I elected to make the JS class as a layer so that it would be easier to create a version for purePDF if I ever get it to work!</p>
<p>So, here is the &#8220;proof of concept&#8221; source code.</p>
<p>First, the ActionScript class that exposes Javascript-friendly methods. Compile this as per Part 1 of this article.</p>
<p><pre class="brush: as3;">
package {

    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;

    import org.alivepdf.pdf.PDF;
    import org.alivepdf.saving.Method;
    import org.alivepdf.fonts.* ;
    import org.alivepdf.pages.Page;
    import org.alivepdf.display.Display;
    import org.alivepdf.layout.* ;
    import org.alivepdf.links.* ;

    import mx.utils.UIDUtil;

    import flash.filesystem.FileStream;
    import flash.filesystem.File;
    import flash.filesystem.FileMode;

    import flash.utils.ByteArray;

    public class alivePDFWrapper extends Sprite {
        private
        var pdf: PDF;
        private
        var file: File;

        public function alivePDFWrapper() {}

        // The translate methods convert the integers passed from the javascript to
        // whatever correct data types AlivePDF uses
        private function translateSize(size: int): Size {
            var s: Size = Size.A4;
            switch (size) {
            case 0:
                s = Size.A3;
                break;
            case 1:
                s = Size.A4;
                break;
            case 2:
                s = Size.A5;
                break;
            case 3:
                s = Size.LEGAL;
                break;
            case 4:
                s = Size.LETTER;
                break;
            case 5:
                s = Size.TABLOID;
                break;
            }
            return s;
        }

        private function translateOrientation(orientation: int): String {
            var o: String = Orientation.PORTRAIT;
            switch (orientation) {
            case 0:
                o = Orientation.PORTRAIT;
                break;
            case 1:
                o = Orientation.LANDSCAPE;
                break;
            }
            return o;
        }

        private function translateUnit(unit: int): String {
            var u: String = Unit.MM;
            switch (unit) {
            case 0:
                u = Unit.MM;
                break;
            case 1:
                u = Unit.CM;
                break;
            case 2:
                u = Unit.INCHES;
                break;
            case 3:
                u = Unit.POINT;
                break;
            }
            return u;
        }

        private function translateDisplayZoom(dzoom: int): String {
            var dz: String = Display.FULL_PAGE;
            switch (dzoom) {
            case 0:
                dz = Display.DEFAULT;
                break;
            case 1:
                dz = Display.FULL_PAGE;
                break;
            case 2:
                dz = Display.FULL_WIDTH;
                break;
            case 3:
                dz = Display.REAL;
                break;
            }
            return dz;
        }

        private function translateDisplayLayout(dlayout: int): String {
            var dl: String = Layout.SINGLE_PAGE;
            switch (dlayout) {
            case 0:
                dl = Layout.SINGLE_PAGE;
                break;
            case 1:
                dl = Layout.ONE_COLUMN;
                break;
            case 2:
                dl = Layout.TWO_COLUMN_LEFT;
                break;
            case 3:
                dl = Layout.TWO_COLUMN_RIGHT;
                break;
            }
            return dl;
        }

        public function newPDF(size: int, orientation: int, unit: int): void {
            var s: Size = translateSize(size);
            var o: String = translateOrientation(orientation);
            var u: String = translateUnit(unit);

            pdf = new PDF(o, u, s);

            //var myCoreFont:IFont = new CoreFont ( FontFamily.HELVETICA_BOLD );
            var myCoreFont: IFont = new CoreFont(FontFamily.HELVETICA);
            pdf.setFont(myCoreFont, 12);

        }

        public function setDisplayMode(displayZoom: int, displayLayout: int): void {
            var dz: String = translateDisplayZoom(displayZoom);
            var dl: String = translateDisplayLayout(displayLayout);

            pdf.setDisplayMode(dz, dl);
        }

        public function newPage(size: int, orientation: int,unit: int): void {
            var s: Size = translateSize(size);
            var o: String = translateOrientation(orientation);
            var u: String = translateUnit(unit);
            var newPage: Page = new Page(o, u, s);
            pdf.addPage(newPage);
        }

        public function addPage(): void {
            pdf.addPage();
        }

        public function writeText(lineHeight: Number, text: String, link: ILink = null): void {
            pdf.writeText(lineHeight, text, link);
        }

        public function saveToFileAIR(fname: String): void {
            // Save to file for AIR
            var fs: FileStream = new FileStream();
            file = new File(fname);
            fs.open(file, FileMode.WRITE);
            var bytes: ByteArray = pdf.save(Method.LOCAL);
            fs.writeBytes(bytes);
            fs.close();
        }

    }
}
</pre></p>
<p>The Javascript interface (so far). Save this to /js folder in your AIR app.</p>
<p><pre class="brush: jscript;">
function jsPDF() {
    // Define constants
    this.size = {
        A3: 0,
        A4: 1,
        A5: 2,
        LEGAL: 3,
        LETTER: 4,
        TABLOID: 5
    }
    this.unit = {
        MM: 0,
        CM: 1,
        INCHES: 2,
        POINT: 3
    }
    this.orientation = {
        PORTRAIT: 0,
        LANDSCAPE: 1
    }
    this.displayZoom = {
        DEFAULT: 0,
        FULL_PAGE: 1,
        FULL_WIDTH: 2,
        REAL: 3
    }
    this.displayLayout = {
        SINGLE_PAGE: 0,
        ONE_COLUMN: 1,
        TWO_COLUMN_LEFT: 2,
        TWO_COLUMN_RIGHT: 3
    }

    // Load the ActionScript Library (ie alivePDF + wrapper class)
    this.ASlib = new window.runtime.alivePDFWrapper();

    // Create a new PDF instance
    this.newPDF = function (size, orientation, unit) {
        this.ASlib.newPDF(size, orientation, unit);
    }
    // Set the display mode for the PDF when displayed in the reader
    this.setDisplayMode = function (displayZoom, displayLayout) {
        this.ASlib.setDisplayMode(displayZoom, displayLayout);
    }
    // Create a new page and add it to the pdf document
    this.newPage = function (size, orientation, unit) {
        this.ASlib.newPage(size, orientation, unit);
    }

    this.addPage = function () {
        this.ASlib.addPage();
    }

    this.writeText = function (lineHeight, text, link) {
        this.ASlib.writeText(lineHeight, text, link);
    }

    this.saveToFileAIR = function (fname) {
        this.ASlib.saveToFileAIR(fname);
    }
}
</pre></p>
<p>The AIR app:</p>
<p><pre class="brush: jscript;">
&lt;html&gt;
    
    &lt;head&gt;
        &lt;title&gt;
            Test alivePDF
        &lt;/title&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;lib/air/AIRAliases.js&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;lib/alivePDFWrapper.swf&quot; type=&quot;application/x-shockwave-flash&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;js/jspdf.js&quot;&gt;&lt;/script&gt;

        &lt;script&gt;

            var mypdf = new jsPDF();

            mypdf.newPDF(mypdf.size.A4, mypdf.orientation.PORTRAIT, mypdf.unit.MM);

            //mypdf.setDisplayMode(mypdf.displayZoom.FULL_PAGE,mypdf.displayLayout.SINGLE_PAGE);
            mypdf.setDisplayMode(mypdf.displayZoom.FULL_PAGE, mypdf.displayLayout.TWO_COLUMN_LEFT);

            mypdf.newPage(mypdf.size.A4, mypdf.orientation.LANDSCAPE, mypdf.unit.MM);

            mypdf.writeText(10, &quot;Just one line on the first page!&quot;);

            mypdf.newPage(mypdf.size.A5, mypdf.orientation.PORTRAIT, mypdf.unit.MM);

            mypdf.writeText(10, &quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\nPraesent vel lectus lorem. Phasellus convallis, tortor a venenatis mattis, erat mi euismod tellus, in fermentum sapien nibh sit amet urna. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent tellus libero, lacinia ac egestas eget, interdum quis purus. Donec ut nisl metus, sit amet viverra turpis. Mauris ultrices dapibus lacus non ultrices. Cras elementum luctus mauris, vitae eleifend diam accumsan ut. Aliquam erat volutpat. Suspendisse placerat nibh in libero tincidunt a elementum mi vehicula. Donec lobortis magna vel nibh mollis tempor. Maecenas et elit nunc. Nam non auctor orci. Aliquam vel velit vel mi adipiscing semper in ac orci. Vestibulum commodo sem eget tortor lobortis semper. Ut sit amet sapien non velit rutrum egestas sollicitudin in elit. Fusce laoreet leo a sem mattis iaculis&quot;);

            mypdf.saveToFileAIR(&quot;C:/CFusionMX7/wwwroot/Sites/TestAS/test2.pdf&quot;); // Set YOUR path here

        &lt;/script&gt;
    &lt;/head&gt;
    
    &lt;body&gt;
    &lt;/body&gt;

&lt;/html&gt;
</pre></p>
<p>I will continue to add functionality and test the AS and JS classes above. I will update the code above as I do. I am very interested to see if others find this idea has potential.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/murrayhopkins.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/murrayhopkins.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/murrayhopkins.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/murrayhopkins.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/murrayhopkins.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/murrayhopkins.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/murrayhopkins.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/murrayhopkins.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/murrayhopkins.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/murrayhopkins.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/murrayhopkins.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/murrayhopkins.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/murrayhopkins.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/murrayhopkins.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=108&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bab3d6eac3bdc2e530db285f993b1f0d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">murrah</media:title>
		</media:content>
	</item>
		<item>
		<title>500 Null errors with POIutility &#8211; java.lang.OutOfMemoryError</title>
		<link>http://murrayhopkins.wordpress.com/2010/12/11/500-null-errors-with-poiutility-java-lang-outofmemoryerror/</link>
		<comments>http://murrayhopkins.wordpress.com/2010/12/11/500-null-errors-with-poiutility-java-lang-outofmemoryerror/#comments</comments>
		<pubDate>Sat, 11 Dec 2010 10:47:39 +0000</pubDate>
		<dc:creator>Murray Hopkins</dc:creator>
				<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://murrayhopkins.wordpress.com/?p=81</guid>
		<description><![CDATA[I use Ben Nadel&#8217;s great POIUtility custom tags to create Excel spreadsheets in Coldfusion MX 7. I have two applications that run on a shared server. Occassionally, the spreadsheet generation stops with the dreaded 500 Null error and I can finally shed some light on the problem. I can often rerun the same generation process [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=81&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I use Ben Nadel&#8217;s great <a title="POIUtility" href="http://www.bennadel.com/projects/poi-utility.htm" target="_blank">POIUtility</a> custom tags to create Excel spreadsheets in Coldfusion MX 7. I have two applications that run on a shared server. Occassionally, the spreadsheet generation stops with the dreaded 500 Null error and I can finally shed some light on the problem. I can often rerun the same generation process with the same data and sometimes it works, sometimes not. Frustratingly, I could not get it to fail on my local development machine until today &#8211; when I threw a much larger dataset at it and finally it crashed with the 500 Null error.</p>
<p>So, digging into my exception.log file  I found what I had suspected was probably happenning on the shared server but couldnt prove  &#8211; <strong>java.lang.OutOfMemoryError.</strong> My service provider said they couldnt see any errors in the log files which wasnt helping my debug efforts!</p>
<p>The final spreadsheet is 1,491 kb on the drive and is 187 columns x 380 rows = 71,060 cells.</p>
<p>I set up some tests on my local development machine and using the same dataset, adjusted the JVM settings and restarted CF each time to work out which setting was the problem. Here are the results:</p>
<table>
<tbody>
<tr>
<td>JVM Heap size Mb</td>
<td>MaxPermSize Mb</td>
<td>Worked?</td>
</tr>
<tr>
<td>512</td>
<td>64</td>
<td>No</td>
</tr>
<tr>
<td>750</td>
<td>64</td>
<td>No</td>
</tr>
<tr>
<td>750</td>
<td>512</td>
<td>No</td>
</tr>
<tr>
<td>925</td>
<td>64</td>
<td>Yes</td>
</tr>
<tr>
<td>925</td>
<td>512</td>
<td>Yes</td>
</tr>
<tr>
<td>1024</td>
<td>64</td>
<td>Yes</td>
</tr>
<tr>
<td>1024</td>
<td>128</td>
<td>Yes</td>
</tr>
<tr>
<td>1024</td>
<td>512</td>
<td>Yes</td>
</tr>
</tbody>
</table>
<p>So, it looks like the heap size is the critical setting.</p>
<p>Using <code> CreateObject("java","java.lang.Runtime").getRuntime() </code> and <code>maxMemory = runtime.maxMemory()</code> it looks like the server setting is probably 512Mb.</p>
<p>Interestingly, I also used the java <code>runtime.freeMemory()</code> in the cell.cfm custom tag (using cflog) whenever a new cell object was created to monitor the memory useage and even when the 500 Null errors occurred the memory always seemed to be at least approx 28 Mb and when the last log entry was written each time there was substantially more than that! I guess I was expecting the freeMemory to fall to something close to zero. My guess is that the garbage collection or some other process must have been grabbing some memory?</p>
<p>Now, I just need to convince my service provider to increase their settings. Or, find another service provider!</p>
<p>I hope this helps others with a similar problem.</p>
<p>Cheers,<br />
Murray</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/murrayhopkins.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/murrayhopkins.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/murrayhopkins.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/murrayhopkins.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/murrayhopkins.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/murrayhopkins.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/murrayhopkins.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/murrayhopkins.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/murrayhopkins.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/murrayhopkins.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/murrayhopkins.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/murrayhopkins.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/murrayhopkins.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/murrayhopkins.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=81&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://murrayhopkins.wordpress.com/2010/12/11/500-null-errors-with-poiutility-java-lang-outofmemoryerror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bab3d6eac3bdc2e530db285f993b1f0d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">murrah</media:title>
		</media:content>
	</item>
		<item>
		<title>A tale of two reel mowers</title>
		<link>http://murrayhopkins.wordpress.com/2010/04/18/a-tale-of-two-reel-mowers/</link>
		<comments>http://murrayhopkins.wordpress.com/2010/04/18/a-tale-of-two-reel-mowers/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 08:07:47 +0000</pubDate>
		<dc:creator>Murray Hopkins</dc:creator>
				<category><![CDATA[Gardening]]></category>
		<category><![CDATA[mower]]></category>
		<category><![CDATA[reel]]></category>

		<guid isPermaLink="false">http://murrayhopkins.wordpress.com/?p=73</guid>
		<description><![CDATA[Yes, that&#8217;s reel not real! Having only a small area of lawn I didn&#8217;t want to buy a power mower of any kind &#8211; petrol or electric. A reel mower is the kind that gets its energy from me pushing it. It is a great feeling to be able to get it out of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=73&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yes, that&#8217;s <strong>reel </strong>not <em>real</em>!</p>
<p>Having only a small area of lawn I didn&#8217;t want to buy a power mower of any kind &#8211; petrol or electric. A reel mower is the kind that gets its energy from me pushing it. It is a great feeling to be able to get it out of the shed with one hand, push it quietly around and feel it slicing the grass (rather than bludgeoning it!). But I am getting ahead of myself here &#8230;</p>
<p>I went off to the hardware store and the only reel mower they had was a Talon brand. After I used it a few times, the gear inside the wheel broke &#8211; crappy casting. The store happily exchanged it. <em>I</em> wasnt so happy since all that metal and plastic probably ended up in landfill. Maybe they recycled it but I doubt it.</p>
<p>Other things that I didn&#8217;t like:</p>
<ol>
<li>It is really hard to adjust the cutters. A reel mower acts like a shear to slice the grass and for it to work properly you need to be able to adjust it so that the stationary bar and the rotating &#8220;knives&#8221; come very close together as it rotates.</li>
<li>Small people (eg 12 year old&#8217;s) can&#8217;t use it because the handles are at their chest height so when they push it the handles just go up into the air instead of the energy going into moving the mower along.</li>
<li>It is slow to adjust the cutting height. Normally you would have it at a set height so that wouldn&#8217;t be important. However, when I took it to cut someone else&#8217;s grass (which was very long and tough) I needed to do it in two passes. It was annoying to have to unscrew bits simply to make it cut higher.</li>
</ol>
<h2><strong>Then, a miracle occurred!</strong></h2>
<p>While out for an early morning walk someone had left a Flymo brand reel mower (model H33) on the footpath with a one word sign on it &#8211; <strong>FREE!</strong> So, why not me, I thought? It looked like it was working and sure enough it did! And it is a dream after the other one!</p>
<p>Good points (I haven&#8217;t found any bad ones so far):</p>
<ol>
<li>Cutter adjustment is by a spring-loaded &#8220;wing nut&#8221; &#8211; done accurately in seconds.</li>
<li>The handles go very low so small people can use it.</li>
<li>Height adjustment is also done in seconds.</li>
<li>The gearing is better than the Talon so the reel spins faster and easier.</li>
</ol>
<p>Brilliant! I have just come in after a peaceful, quiet, CO2-free easy mowing session where all I could hear was the gentle whirr of the grass being sliced to size. I just love things that are designed properly!</p>
<p>I hope this encourages someone to try a reel mower and not to buy the Talon brand &#8211; it&#8217;s rubbish!</p>
<p>Time for a beer to celebrate!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/murrayhopkins.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/murrayhopkins.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/murrayhopkins.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/murrayhopkins.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/murrayhopkins.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/murrayhopkins.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/murrayhopkins.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/murrayhopkins.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/murrayhopkins.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/murrayhopkins.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/murrayhopkins.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/murrayhopkins.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/murrayhopkins.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/murrayhopkins.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=73&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://murrayhopkins.wordpress.com/2010/04/18/a-tale-of-two-reel-mowers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bab3d6eac3bdc2e530db285f993b1f0d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">murrah</media:title>
		</media:content>
	</item>
		<item>
		<title>CF UDF countArbitraryDaysExcluding</title>
		<link>http://murrayhopkins.wordpress.com/2010/03/04/cf-udf-countarbitrarydaysexcluding/</link>
		<comments>http://murrayhopkins.wordpress.com/2010/03/04/cf-udf-countarbitrarydaysexcluding/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 00:08:32 +0000</pubDate>
		<dc:creator>Murray Hopkins</dc:creator>
				<category><![CDATA[Coldfusion]]></category>

		<guid isPermaLink="false">http://murrayhopkins.wordpress.com/?p=67</guid>
		<description><![CDATA[My countArbitraryDaysExcluding UDF has been released on CFLIB.org. You can find it here: http://www.cflib.org/udf/countArbitraryDaysExcluding See the comments there. But basically, count all the days in a date range (eg all Mondays) but exclude certain dates (eg for public holidays). These exclusions may be specific dates or patterns ( eg YYYY-1-1 ) &#8211; New Years Day [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=67&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My countArbitraryDaysExcluding UDF has been released on CFLIB.org. You can find it here:</p>
<p><a href="http://www.cflib.org/udf/countArbitraryDaysExcluding">http://www.cflib.org/udf/countArbitraryDaysExcluding</a></p>
<p>See the comments there. But basically, count all the days in a date range (eg all Mondays) but exclude certain dates (eg for public holidays). These exclusions may be specific dates or patterns ( eg YYYY-1-1 ) &#8211; New Years Day in any year so you dont need to update your code once a pattern is defined.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/murrayhopkins.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/murrayhopkins.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/murrayhopkins.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/murrayhopkins.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/murrayhopkins.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/murrayhopkins.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/murrayhopkins.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/murrayhopkins.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/murrayhopkins.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/murrayhopkins.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/murrayhopkins.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/murrayhopkins.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/murrayhopkins.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/murrayhopkins.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=67&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://murrayhopkins.wordpress.com/2010/03/04/cf-udf-countarbitrarydaysexcluding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bab3d6eac3bdc2e530db285f993b1f0d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">murrah</media:title>
		</media:content>
	</item>
		<item>
		<title>Using an OR in a MySQL Select If statement</title>
		<link>http://murrayhopkins.wordpress.com/2010/03/04/using-an-or-in-a-mysql-select-if-statement/</link>
		<comments>http://murrayhopkins.wordpress.com/2010/03/04/using-an-or-in-a-mysql-select-if-statement/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 00:03:23 +0000</pubDate>
		<dc:creator>Murray Hopkins</dc:creator>
				<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">http://murrayhopkins.wordpress.com/?p=62</guid>
		<description><![CDATA[It took a while to find the (sort of) obvious. I needed a Select statement that used the IF function and wanted the condition part to have an OR in it. The standard syntax is: eg with an OR<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=62&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It took a while to find the (sort of) obvious. I needed a Select statement that used the IF function and wanted the condition part to have an OR in it.</p>
<p>The standard syntax is:<br />
<pre class="brush: plain;">if (condition, do this if true, do this if false)</pre><br />
eg<br />
<pre class="brush: plain;">if (questions.type='F', concat(a,b,c), concat(a,b,c,d,e) )</pre><br />
with an OR<br />
<pre class="brush: plain;">if (questions.type='F'||questions.type='G', concat(a,b,c), concat(a,b,c,d,e) )</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/murrayhopkins.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/murrayhopkins.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/murrayhopkins.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/murrayhopkins.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/murrayhopkins.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/murrayhopkins.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/murrayhopkins.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/murrayhopkins.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/murrayhopkins.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/murrayhopkins.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/murrayhopkins.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/murrayhopkins.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/murrayhopkins.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/murrayhopkins.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=62&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://murrayhopkins.wordpress.com/2010/03/04/using-an-or-in-a-mysql-select-if-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bab3d6eac3bdc2e530db285f993b1f0d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">murrah</media:title>
		</media:content>
	</item>
		<item>
		<title>Problem with CF7 dateDiff function &#8211; use countArbitraryDays instead</title>
		<link>http://murrayhopkins.wordpress.com/2010/01/05/problem-with-cf7-datediff-function-use-countarbitrarydays-instead/</link>
		<comments>http://murrayhopkins.wordpress.com/2010/01/05/problem-with-cf7-datediff-function-use-countarbitrarydays-instead/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 01:47:50 +0000</pubDate>
		<dc:creator>Murray Hopkins</dc:creator>
				<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://murrayhopkins.wordpress.com/?p=50</guid>
		<description><![CDATA[The CF7 livedocs dont mention anything about this so I added a comment. This is more on the subject. There doesnt seem to be a way to DateDiff with weekdays (ie dont count weekends). The docs say: w: Weekdays (same as ww) ww: Weeks ie w and ww are synonymous, both mean weeks. That is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=50&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The CF7 livedocs dont mention anything about this so I added a comment. This is more on the subject.</p>
<p>There doesnt seem to be a way to DateDiff with weekdays (ie dont count weekends).</p>
<p>The docs say:<br />
w: Weekdays (same as ww)<br />
ww: Weeks</p>
<p>ie w and ww are synonymous, both mean weeks. That is true when you test it (see below).</p>
<p>The docs for DateAdd however say:<br />
w: Weekday<br />
ww: Week</p>
<p>ie w is days and ww is weeks! Inconsistant.</p>
<p>This code generates the output shown below:</p>
<p><pre class="brush: coldfusion;">
&lt;cfset date1 = CreateDateTime(2009,10,15,21,00,00)&gt;

&lt;cfoutput&gt;date1=#date1#&lt;/cfoutput&gt;

&lt;table border=1&gt;
&lt;tr&gt;
	&lt;td&gt;i&lt;/td&gt;
	&lt;td&gt;Day() of&lt;br&gt;dateAdd('d',i,date1)&lt;/td&gt;
	&lt;td&gt;Day() of&lt;br&gt;dateAdd('w',i,date1)&lt;/td&gt;
	&lt;td&gt;dateDiff('d',date1,date2)&lt;/td&gt;
	&lt;td&gt;dateDiff('w',date1,date2)&lt;/td&gt;
&lt;/tr&gt;

&lt;cfloop index=&quot;i&quot; from=&quot;0&quot; to=&quot;10&quot;&gt;
	&lt;cfoutput&gt;
		&lt;cfset date2=dateAdd('d',i,date1)&gt;
		&lt;tr&gt;
			&lt;td&gt;#i#&lt;/td&gt;
			&lt;td&gt;#day(dateAdd('d',i,date1))#&lt;/td&gt;
			&lt;td&gt;#day(dateAdd('w',i,date1))#&lt;/td&gt;
			&lt;td&gt;#dateDiff('d',date1,date2)#&lt;/td&gt;
			&lt;td&gt;#dateDiff('w',date1,date2)#&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/cfoutput&gt;
&lt;/cfloop&gt;

&lt;/table&gt;

</pre></p>
<p>date1={ts &#8217;2009-10-15 21:00:00&#8242;}</p>
<table border="1">
<tbody>
<tr>
<td>i</td>
<td>Day() of<br />
dateAdd(&#8216;d&#8217;,i,date1)</td>
<td>Day() of<br />
dateAdd(&#8216;w&#8217;,i,date1)</td>
<td>dateDiff(&#8216;d&#8217;,date1,date2)</td>
<td>dateDiff(&#8216;w&#8217;,date1,date2)</td>
</tr>
<tr>
<td>0</td>
<td>15</td>
<td>15</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>1</td>
<td>16</td>
<td>16</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td>2</td>
<td>17</td>
<td>19</td>
<td>2</td>
<td>0</td>
</tr>
<tr>
<td>3</td>
<td>18</td>
<td>20</td>
<td>3</td>
<td>0</td>
</tr>
<tr>
<td>4</td>
<td>19</td>
<td>21</td>
<td>4</td>
<td>0</td>
</tr>
<tr>
<td>5</td>
<td>20</td>
<td>22</td>
<td>5</td>
<td>0</td>
</tr>
<tr>
<td>6</td>
<td>21</td>
<td>23</td>
<td>6</td>
<td>0</td>
</tr>
<tr>
<td>7</td>
<td>22</td>
<td>26</td>
<td>7</td>
<td>1</td>
</tr>
<tr>
<td>8</td>
<td>23</td>
<td>27</td>
<td>8</td>
<td>1</td>
</tr>
<tr>
<td>9</td>
<td>24</td>
<td>28</td>
<td>9</td>
<td>1</td>
</tr>
<tr>
<td>10</td>
<td>25</td>
<td>29</td>
<td>10</td>
<td>1</td>
</tr>
</tbody>
</table>
<p>As you can see, the dateDiff(&#8220;w&#8221;&#8230;) does what the docs say but not what you might expect.</p>
<p>And dont forget that for DateDiff and DateAdd a &#8220;day&#8221; is a 24 hour period, so dateDiff(&#8216;d&#8217;,{a date at 11pm},{the next day at 6am}) returns 0, not 1.</p>
<p>So, my solution (after testing various options including my own) was to use this <a href="http://www.cflib.org/udf/countArbitraryDays">http://www.cflib.org/udf/countArbitraryDays</a> which seems to work correctly. It is also correct (IMJ) where the first date is (say) 11pm and the second date is at (say) 6am ie not whole 24 hour periods. countArbitraryDays counts these as whole days even if they are not 24 hours apart. That is what I wanted &#8211; if it is the next day, it is 1 day irresepective of whether a full 24 hours have elapsed.</p>
<p>Now, back to the job!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/murrayhopkins.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/murrayhopkins.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/murrayhopkins.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/murrayhopkins.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/murrayhopkins.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/murrayhopkins.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/murrayhopkins.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/murrayhopkins.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/murrayhopkins.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/murrayhopkins.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/murrayhopkins.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/murrayhopkins.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/murrayhopkins.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/murrayhopkins.wordpress.com/50/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=50&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://murrayhopkins.wordpress.com/2010/01/05/problem-with-cf7-datediff-function-use-countarbitrarydays-instead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bab3d6eac3bdc2e530db285f993b1f0d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">murrah</media:title>
		</media:content>
	</item>
		<item>
		<title>#Value! error when using builtin POI in ColdFusion MX7</title>
		<link>http://murrayhopkins.wordpress.com/2008/12/17/value-error-when-using-builtin-poi-in-coldfusion-mx7/</link>
		<comments>http://murrayhopkins.wordpress.com/2008/12/17/value-error-when-using-builtin-poi-in-coldfusion-mx7/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 04:01:45 +0000</pubDate>
		<dc:creator>Murray Hopkins</dc:creator>
				<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://murrayhopkins.wordpress.com/?p=37</guid>
		<description><![CDATA[CF 7 (and 8, I think) has the java POI library builtin which means that (amongst other things) you can create native Excel spreadsheet files. cfSearching and Ben Nadel&#8217;s great blogs have more details. I used Ben&#8217;s great POI Utility which is a set of custom tags that allows easy creation of XLS files with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=37&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>CF 7 (and 8, I think) has the java POI library builtin which means that (amongst other things) you can create native Excel spreadsheet files. <a href="http://cfsearching.blogspot.com/2008/08/poi-examples-part-i.html">cfSearching</a> and <a href="http://www.bennadel.com/projects/poi-utility.htm">Ben Nadel&#8217;s</a> great blogs have more details.</p>
<p>I used Ben&#8217;s great POI Utility which is a set of custom tags that allows easy creation of XLS files with CSS styles for formatting. Fantastic stuff. However, when I created a cell containing the Excel COUNTIF() function, the cell displayed the <strong>#Value!</strong> error even though there was no error. By double clicking the cell then pressing enter, the error went away and the correct result was displayed.</p>
<p>After some googling I discovered that there was a bug in earlier versions of the POI java library that is shipped with CF7 (and 8??). So, nothing to do with the POI Utility, everything to do with the underlying Java.</p>
<p>Time to get the latest version of the POI Java jars and use Mark Mandel&#8217;s brilliant <a href="http://www.compoundtheory.com/?action=javaloader.index">JavaLoader.cfc</a> to load them into CF. If you need to know how to do that, see <a href="http://cfsearching.blogspot.com/2008/08/how-to-install-poi-on-coldfusion-8.html">cfSearching&#8217;s post</a> on that.</p>
<p>Once installed, the question was then how to change Ben&#8217;s POI Utility custom tags to use the new version of the jars instead of the builtin version. What I did was the following which solved the problem. I should say at the outset that I am not fluent in cf custom tags (I use objects instead) so there might be a more elegant way to acheive this.</p>
<p>First, add the following function to the POI/document.cfm page:</p>
<p><pre class="brush: xml;">
&lt;cffunction name=&quot;getJavaClass&quot; returntype=&quot;any&quot; hint=&quot;&quot; access=&quot;public&quot;&gt;
	&lt;cfargument name=&quot;javaLoader&quot; type=&quot;any&quot; required=&quot;yes&quot; hint=&quot;&quot;&gt;
	&lt;cfargument name=&quot;className&quot; type=&quot;string&quot; required=&quot;yes&quot; hint=&quot;&quot;&gt;
 &lt;cfscript&gt;
	if (isObject(arguments.javaLoader)) {
		return arguments.javaLoader.create(arguments.className);
	} else {
		return CreateObject(&quot;java&quot;, arguments.className);
	}
&lt;/cfscript&gt;
&lt;/cffunction&gt;
</pre></p>
<p>This function will be used to load the java jars using the javaLoader if it is passed in, or the normal CreateObject if there is no javaLoader passed in.</p>
<p>Then, in <strong>poi/document.cfm</strong>:<br />
after</p>
<p><pre class="brush: xml;">
		&lt;cfparam
			name=&quot;ATTRIBUTES.Style&quot;
			type=&quot;string&quot;
			default=&quot;&quot;
			/&gt;
</pre></p>
<p>add the following attribute and variables declaration:</p>
<p><pre class="brush: xml;">
		&lt;cfparam
			name=&quot;ATTRIBUTES.javaLoader&quot;
			type=&quot;any&quot;
			default=&quot;&quot;
			/&gt;

		 &lt;cfset variables.javaLoader = ATTRIBUTES.javaLoader&gt;
</pre></p>
<p>Then, change all occurrances of</p>
<p><pre class="brush: xml;">
CreateObject( &quot;java&quot;,
eg
&lt;cfset VARIABLES.WorkBook = CreateObject( &quot;java&quot;, &quot;org.apache.poi.hssf.usermodel.HSSFWorkbook&quot; ).Init(
</pre></p>
<p>to</p>
<p><pre class="brush: xml;">
getJavaClass(ATTRIBUTES.javaLoader,
eg
&lt;cfset VARIABLES.WorkBook = getJavaClass(ATTRIBUTES.javaLoader, &quot;org.apache.poi.hssf.usermodel.HSSFWorkbook&quot; ).Init(
</pre></p>
<p>Now, in <strong>poi/cell.cfm</strong>, change:</p>
<p><pre class="brush: xml;">
CreateObject( &quot;java&quot;, &quot;org.apache.poi.hssf.util.Region&quot; ).Init(
</pre></p>
<p>to</p>
<p><pre class="brush: xml;">
VARIABLES.DocumentTag.getJavaClass(VARIABLES.DocumentTag.javaLoader, &quot;org.apache.poi.hssf.util.Region&quot; ).Init(
</pre></p>
<p>That fragment uses the function and variables that are located on the document.cfm page.</p>
<p>Finally, when you use the <strong>poi:document</strong> tag on your page, pass the instance of your javaLoader, eg:</p>
<p><pre class="brush: xml;">
&lt;poi:document
	javaLoader=&quot;#variables.javaLoader#&quot;
	name=&quot;REQUEST.ExcelData&quot;
	file=&quot;#xlsfname#&quot;
	style=&quot;font-family: verdana ; font-size: 10pt ; color: black ; white-space: nowrap ;&quot;&gt;
</pre></p>
<p>After those small changes, the #Value! error went away! Yay!!</p>
<p>Thanks again to Mark, Ben and Leigh for making all this possible in the first place.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/murrayhopkins.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/murrayhopkins.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/murrayhopkins.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/murrayhopkins.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/murrayhopkins.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/murrayhopkins.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/murrayhopkins.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/murrayhopkins.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/murrayhopkins.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/murrayhopkins.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/murrayhopkins.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/murrayhopkins.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/murrayhopkins.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/murrayhopkins.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=murrayhopkins.wordpress.com&amp;blog=1878301&amp;post=37&amp;subd=murrayhopkins&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://murrayhopkins.wordpress.com/2008/12/17/value-error-when-using-builtin-poi-in-coldfusion-mx7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bab3d6eac3bdc2e530db285f993b1f0d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">murrah</media:title>
		</media:content>
	</item>
	</channel>
</rss>
