<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-20432421</id><updated>2011-12-11T12:51:02.497-05:00</updated><category term='PHP'/><category term='extensions'/><category term='Firefox'/><category term='add-ons'/><category term='icons'/><category term='Maven'/><category term='programming'/><category term='Eclipse'/><category term='PMD'/><category term='customer service'/><category term='review'/><category term='Java'/><category term='Oracle'/><category term='Sonar'/><category term='Facebook'/><category term='computers'/><title type='text'>John's Technical Blog</title><subtitle type='html'>Questions and solutions relating primarily to web page development. I have been developing web pages since 1994. I hope my articles will be helpful to you.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>27</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-20432421.post-3393487065824190768</id><published>2011-10-31T09:54:00.000-05:00</published><updated>2011-10-31T12:39:23.216-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Bin2Txt - Remove Non-printable Characters from a Text File with Java</title><content type='html'>I recently was dealing with some DB2 "unload" (e.g., export) files that I wanted to parse and then load into Oracle. I found that the unload files use a lot of binary characters, which makes it very difficult to parse. I wrote the following Java class to convert the unprintable characters into a tilde (which is a character that does not occur in the data). This resulted in DB2 unload files that were parsable as fixed-width data files.&lt;br /&gt;The main problem this approach does not attempt to solve is that the DB2 unload files save numeric fields as the actual value, not the digit equivalent (i.e., the number 84 is unloaded as the ASCII-equivalent "T", not "84"). This code obviously does not reference the DB2 "punch" (e.g., parse instruction) files, so it makes no attempt to parse the files into fields itself - that is a separate exercise in my case. BTW, if there is a good way to import these files into Oracle automatically, please let me know, as I have not been able to find a better solution.&lt;br /&gt;This code is fairly generic, and can be used for other purposes beyond converting DB2 unload files, so if you have a need to replace non-printable characters in text files, you can start with this code base.&lt;br /&gt;&lt;hr /&gt;&lt;div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;package&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;com.threeleaf.bin2txt;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; java.io.File;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;java.io.FileInputStream;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;java.io.FileOutputStream;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; java.io.IOException;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; java.io.InputStream;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;java.io.OutputStream;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;/**&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;* Purpose is to read a file and replace non&lt;/span&gt;&lt;span style="color: #7f7f9f; font-family: Consolas; font-size: 10pt;"&gt;-&lt;/span&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;printablecharacters with a given character.&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;* Specifically, I want to use this to make DB2unload files parsable with other applications so&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;* that the data can be imported into Oracle.&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;* &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f9fbf; font-family: Consolas; font-size: 10pt;"&gt;@author&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt; John A. Marsh&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;* &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f9fbf; font-family: Consolas; font-size: 10pt;"&gt;@since&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt; 2011&lt;/span&gt;&lt;span style="color: #7f7f9f; font-family: Consolas; font-size: 10pt;"&gt;-&lt;/span&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;10&lt;/span&gt;&lt;span style="color: #7f7f9f; font-family: Consolas; font-size: 10pt;"&gt;-&lt;/span&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;27&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; Bin2Txt {&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;/**&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Run this class from the command line with:&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* &lt;/span&gt;&lt;span style="color: #7f7f9f; font-family: Consolas; font-size: 10pt;"&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;code&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;java Bin2Txt&amp;lt;pathAndFilename&amp;gt;&lt;/span&gt;&lt;span style="color: #7f7f9f; font-family: Consolas; font-size: 10pt;"&gt;&lt;/span&gt;&lt;/code&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;.&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* &lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f9fbf; font-family: Consolas; font-size: 10pt;"&gt;@param&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt; args&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the filename to convert&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f9fbf; font-family: Consolas; font-size: 10pt;"&gt;@throws&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt; IOException&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Signals that an I/Oexception (e.g., file not found) has occurred.&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f5fbf; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;static&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; main (&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; String[] args) &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;throws&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; IOException {&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;byte&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; ASCII_SPACE = 32;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;byte&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; ASCII_CR = 13;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;byte&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; ASCII_LF = 10;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;byte&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; ASCII_TILDE = 126;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; File file = &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; File(args[0]);&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; InputStreaminputStream = &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; FileInputStream(file);&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; fileLength =file.length();&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;/*&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Array needs to be created withan int type, so need to check to ensure that file is&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * not larger thanInteger.MAX_VALUE.&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; (fileLength &amp;gt; Integer.&lt;/span&gt;&lt;i&gt;&lt;span style="color: #0000c0; font-family: Consolas; font-size: 10pt;"&gt;MAX_VALUE&lt;/span&gt;&lt;/i&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;) {&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;throw&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; IOException(&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: Consolas; font-size: 10pt;"&gt;"File is toobig"&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;);&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;/* Create the byte array to hold the data*/&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;byte&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;[] bytes = &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;byte&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;[(&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;) fileLength];&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;/* Read in the bytes */&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; offset = 0;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; numRead = 0;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;while&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; (offset &amp;lt; bytes.&lt;/span&gt;&lt;span style="color: #0000c0; font-family: Consolas; font-size: 10pt;"&gt;length&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &amp;amp;&amp;amp; (numRead= inputStream.read(bytes, offset, bytes.&lt;/span&gt;&lt;span style="color: #0000c0; font-family: Consolas; font-size: 10pt;"&gt;length&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; - offset)) &amp;gt;= 0) {&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; offset += numRead;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;/* Ensure all the bytes have been read in*/&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; (offset &amp;lt; bytes.&lt;/span&gt;&lt;span style="color: #0000c0; font-family: Consolas; font-size: 10pt;"&gt;length&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;) {&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;throw&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; IOException(&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: Consolas; font-size: 10pt;"&gt;"Could notcompletely read file "&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; + file.getName());&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inputStream.close();&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;for&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; (&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; i = 0; i &amp;lt; bytes.&lt;/span&gt;&lt;span style="color: #0000c0; font-family: Consolas; font-size: 10pt;"&gt;length&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;; i++) {&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; (bytes[i] ==ASCII_CR &amp;amp;&amp;amp; bytes[i + 1] == ASCII_LF) {&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;/*&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Preserve line breaks(carriage return + line feed) by skipping over them.&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Note that I don't checkfor end of file here because I already know my&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * particular files willnever end with a CRLF.&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = i + 2;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; (bytes[i] &amp;lt;ASCII_SPACE || bytes[i] &amp;gt; ASCII_TILDE) {&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;/* Replace allnon-printable characters. */&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bytes[i] = ASCII_TILDE;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;/* Output file name will be the same as theinput, with ".out.txt" added to the end. */&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; OutputStreamoutputStream = &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; FileOutputStream(args[0] + &lt;/span&gt;&lt;span style="color: #2a00ff; font-family: Consolas; font-size: 10pt;"&gt;".out.txt"&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;);&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outputStream.write(bytes);&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outputStream.close();&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; (&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: Consolas; font-size: 10pt;"&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt; ArrayIndexOutOfBoundsException e) {&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;/*&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * If no file was passed on thecommand line, this exception is generated. A message&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * indicating how to the classshould be called is displayed.&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;i&gt;&lt;span style="color: #0000c0; font-family: Consolas; font-size: 10pt;"&gt;out&lt;/span&gt;&lt;/i&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;.println(&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: Consolas; font-size: 10pt;"&gt;"Usage: javaBin2Txt filename\n"&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;);&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;}&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;hr /&gt;Here is a batch file that will convert all the files in a given directory:&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;hr /&gt;&lt;div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;::Directory where Bin2Txt.class is located ::&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;cd&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;C:\projects\workspace\bin2txt\bin\&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;::Put in directory where unload files are ::&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;for&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #ff8000; font-family: 'Courier New'; font-size: 10pt;"&gt;%%f&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt; in&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; ("C:\projects\Database\Unloads\&lt;/span&gt;&lt;b&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;*&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;.txt")&lt;/span&gt;&lt;b&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt; do call&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #0080ff; font-family: 'Courier New'; font-size: 10pt;"&gt; java&lt;/span&gt;&lt;b&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt; com&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;.threeleaf.bin2txt.Bin2Txt&lt;/span&gt;&lt;b&gt;&lt;span style="color: #ff8000; font-family: 'Courier New'; font-size: 10pt;"&gt;%%f&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;hr /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-3393487065824190768?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/3393487065824190768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=3393487065824190768' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/3393487065824190768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/3393487065824190768'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2011/10/bin2txt-remove-non-printable-characters.html' title='Bin2Txt - Remove Non-printable Characters from a Text File with Java'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-793378264967891271</id><published>2011-10-13T16:35:00.001-05:00</published><updated>2011-10-13T16:39:08.295-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='icons'/><category scheme='http://www.blogger.com/atom/ns#' term='extensions'/><category scheme='http://www.blogger.com/atom/ns#' term='add-ons'/><category scheme='http://www.blogger.com/atom/ns#' term='Firefox'/><title type='text'>Solved: Firefox Tab Icons Are Missing</title><content type='html'>I have been frustrated over the last few weeks because I could not figure out why the icons suddenly stopped showing up in Firefox. I have scoured the web and tried several suggestions, but none of them worked for me. I finally got clued in that it might be one of my extensions, and sure enough, going to &lt;code&gt;Help » Restart With Add-ons Disabled&lt;/code&gt; caused the icons to reappear. After a little trial and error I finally found that it was the &lt;strong&gt;Favicon Picker 2&lt;/strong&gt;. I wanted the functionality, so I tried&lt;b&gt; Favicon Picker 3&lt;/b&gt;, but it caused the same problem. I finally found that &lt;strong&gt;Bookmark Favicon Changer&lt;/strong&gt; (&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/bookmark-favicon-changer/"&gt;https://addons.mozilla.org/en-US/firefox/addon/bookmark-favicon-changer/&lt;/a&gt;) allowed me to customize my bookmark icons without causing the tabs to go blank. So, if you find that the favicons in your tabs are absent, give it a try. As of this writing, I am using &lt;b&gt;Firefox 7&lt;/b&gt; and &lt;b&gt;Bookmark Favicon Changer 1.54&lt;/b&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-793378264967891271?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/793378264967891271/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=793378264967891271' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/793378264967891271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/793378264967891271'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2011/10/solved-firefox-tab-icons-are-missing.html' title='Solved: Firefox Tab Icons Are Missing'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-4471915509260145351</id><published>2011-09-13T08:02:00.000-05:00</published><updated>2011-09-13T08:02:25.712-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Interning String Literals In Java</title><content type='html'>&lt;div&gt;A coworker and I were discussing strings, and some of the things we had heard about how the Java compiler stores and retrieves them from memory. We were particularly wondering if constants, local variables, literals, and runtime generated strings were handled differently. I wrote the following JUnit 4 test to show how all these cases are handled (Java JDK 1.6.0_27):&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;font color="#3F5FBF"&gt;&lt;span style="white-space:pre;"&gt;/**&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font color="#3F5FBF"&gt;&lt;span style="white-space:pre;"&gt; * Test string interning affects on literal and runtime strings.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font color="#3F5FBF"&gt;&lt;span style="white-space:pre;"&gt; */&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;public&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;final&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;class&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;StringInternTest {&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font color="#010101"&gt;&lt;span style="white-space:pre;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;   &lt;/span&gt;&lt;/font&gt; &lt;font color="#3F5FBF"&gt;&lt;span style="white-space:pre;"&gt;/**&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font color="#3F5FBF"&gt;&lt;span style="white-space:pre;"&gt;     * String intern test.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font color="#3F5FBF"&gt;&lt;span style="white-space:pre;"&gt;     */&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;   &lt;/span&gt;&lt;/font&gt; &lt;font color="#646464"&gt;&lt;span style="white-space:pre;"&gt;@Test&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;   &lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;public&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;void&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;stringIntern () {&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt;&lt;/font&gt; &lt;font color="#3F7F5F"&gt;&lt;span style="white-space:pre;"&gt;/* literals */&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertEquals&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;,&lt;/span&gt;&lt;/font&gt; &lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertTrue&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;==&lt;/span&gt;&lt;/font&gt; &lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt;&lt;/font&gt; &lt;font color="#3F7F5F"&gt;&lt;span style="white-space:pre;"&gt;/* Compare to an external constant */&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertEquals&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;, Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertTrue&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt;&lt;/font&gt; &lt;font color="#3F7F5F"&gt;&lt;span style="white-space:pre;"&gt;/* Compare locally defined strings. */&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;final&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;String myDateString =&lt;/span&gt;&lt;/font&gt; &lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertEquals&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;, myDateString);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertTrue&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== myDateString);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;final&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;String myDateString2 =&lt;/span&gt;&lt;/font&gt; &lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertEquals&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(myDateString, myDateString2);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertTrue&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(myDateString == myDateString2);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertEquals&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;, myDateString);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertEquals&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;, myDateString2);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertTrue&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== myDateString);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertTrue&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== myDateString2);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt;&lt;/font&gt; &lt;font color="#3F7F5F"&gt;&lt;span style="white-space:pre;"&gt;/* Create new strings at runtime. */&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;final&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;String runtime1 =&lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;new&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;String(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;final&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;String runtime2 =&lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;new&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;String(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertEquals&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;, runtime1);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertEquals&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;, runtime2);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertEquals&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;, runtime1);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertEquals&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;, runtime2);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertEquals&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(runtime1, runtime2);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertFalse&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(runtime1 == runtime2);&lt;/span&gt;&lt;/font&gt; &lt;font color="#3F7F5F"&gt;&lt;span style="white-space:pre;"&gt;// !!!&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertFalse&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== runtime1);&lt;/span&gt;&lt;/font&gt; &lt;font color="#3F7F5F"&gt;&lt;span style="white-space:pre;"&gt;// !!!&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertFalse&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== runtime2);&lt;/span&gt;&lt;/font&gt; &lt;font color="#3F7F5F"&gt;&lt;span style="white-space:pre;"&gt;// !!!&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertFalse&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== runtime1);&lt;/span&gt;&lt;/font&gt; &lt;font color="#3F7F5F"&gt;&lt;span style="white-space:pre;"&gt;// !!!&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertFalse&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== runtime2);&lt;/span&gt;&lt;/font&gt; &lt;font color="#3F7F5F"&gt;&lt;span style="white-space:pre;"&gt;// !!!&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt;&lt;/font&gt; &lt;font color="#3F7F5F"&gt;&lt;span style="white-space:pre;"&gt;/* Intern the runtime strings. */&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;final&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;String interned1 = runtime1.intern();&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt;&lt;/font&gt; &lt;font color="#7F0055"&gt;&lt;span style="white-space:pre;"&gt;&lt;b&gt;final&lt;/b&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;String interned2 = runtime2.intern();&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertTrue&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(interned1 == interned2);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertTrue&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== interned1);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertTrue&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(&lt;/span&gt;&lt;/font&gt;&lt;font color="#2A00FF"&gt;&lt;span style="white-space:pre;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== interned2);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertTrue&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== interned1);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;       &lt;/span&gt; &lt;span style="white-space:pre;"&gt;&lt;i&gt;assertTrue&lt;/i&gt;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;(Constants.&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000C0"&gt;&lt;span style="white-space:pre;"&gt;&lt;i&gt;DATE&lt;/i&gt;&lt;/span&gt;&lt;/font&gt; &lt;font&gt;&lt;span style="white-space:pre;"&gt;== interned2);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font&gt;&lt;span style="white-space:pre;"&gt;    }&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;If you set a break point in this test and examine the variables you will find that Constants.DATE, myDateString, myDateString2, interned1, and interned2 all have the same internal object ID. I learned online that all string literals are supposed to be interned when the application is compiled, which accounts for the variables having the same ID. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Strings stored in runtime1 and runtime2 are each given a unique object ID when instantiated at runtime, and thus return a false when == is tried with any of the interned strings.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Some have suggested that manually interning is better because using == is much faster (5x) than equals() (because comparing object IDs is faster than comparing string lengths || characters). However, others dismiss this as a minor gain at best, and I can certainly see that using == might lead to some hard-to-find bugs if a non-interned string is compared to either an interned or another non-interned string. I also learned that main argument strings (args[]) are not interned.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Interned strings are stored in the PermGen (Permanent Generation) memory, and it is possible to fill up that space with strings if one is not careful.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;References:&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation"&gt;http://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html"&gt;http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://javatechniques.com/public/java/docs/basics/string-equality.html"&gt;http://javatechniques.com/public/java/docs/basics/string-equality.html&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-4471915509260145351?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/4471915509260145351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=4471915509260145351' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/4471915509260145351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/4471915509260145351'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2011/09/interning-string-literals-in-java.html' title='Interning String Literals In Java'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-2697094084995131040</id><published>2011-09-08T09:35:00.000-05:00</published><updated>2011-09-09T10:30:01.735-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Sonar'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle'/><title type='text'>SOLUTION: "SQL driver not found org.apache.derby.jdbc.ClientDriver" When Using Oracle with Sonar and Maven</title><content type='html'>&lt;p&gt;I am new to Sonar and Maven, and have been perplexed for several hours with the "SQL driver not found org.apache.derby.jdbc.ClientDriver" error I was getting when running &lt;code&gt;mvn sonar:sonar&lt;/code&gt; from the Windows command line after starting the Sonar server.&lt;/p&gt;&lt;p&gt;What is not clear in the instructions is that you must modify both &lt;code&gt;&lt;strong&gt;&amp;lt;sonar path&amp;gt;\conf\sonar.properties&lt;/strong&gt;&lt;/code&gt; and &lt;code&gt;&lt;strong&gt;&amp;lt;maven path&amp;gt;\conf\settings.xml&lt;/strong&gt;&lt;/code&gt; to get this to work. The Sonar properties tell the Sonar server what database driver to use in the Sonar server, and the Maven settings file tells Maven what database driver to use when it is running Sonar.&lt;/p&gt;&lt;p&gt;Here are the changes I made to connect to my local Oracle XE instance:&lt;/p&gt;&lt;h2&gt;sonar.properties&lt;/h2&gt;&lt;div style="background: #eee; border: 1px solid black; color: black; font-family: Courier New,Courier,monospace; margin: 5px; padding: 5px; text-align: left;width:100%;overflow-x: auto;"&gt;...&lt;br /&gt;&lt;br /&gt;sonar.jdbc.username:                       sonar&lt;br /&gt;sonar.jdbc.password:                       sonar&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;# Comment the following lines to deactivate the default embedded database.&lt;br /&gt;#sonar.jdbc.url:                            jdbc:derby://localhost:1527/sonar;create=true&lt;br /&gt;#sonar.jdbc.driverClassName:                org.apache.derby.jdbc.ClientDriver&lt;br /&gt;#sonar.jdbc.validationQuery:                values(1)&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;sonar.jdbc.url:                            jdbc:oracle:thin:@localhost:1521:xe&lt;br /&gt;sonar.jdbc.driverClassName:                oracle.jdbc.driver.OracleDriver&lt;br /&gt;sonar.jdbc.validationQuery:                select 1 from dual&lt;/div&gt;&lt;h2&gt;settings.xml&lt;/h2&gt;&lt;div style="background: #eee; border: 1px solid black; color: black; font-family: Courier New,Courier,monospace; margin: 5px; padding: 5px; text-align: left;width:100%;overflow-x: auto;"&gt;&amp;lt;profiles&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;profile&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;id&amp;gt;sonar&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;activation&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;activeByDefault&amp;gt;true&amp;lt;/activeByDefault&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/activation&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;properties&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;sonar.jdbc.url&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;jdbc:oracle:thin:@localhost:1521:xe&amp;lt;/sonar.jdbc.url&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;sonar.jdbc.driver&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oracle.jdbc.driver.OracleDriver&amp;lt;/sonar.jdbc.driver&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;sonar.jdbc.username&amp;gt;sonar&amp;lt;/sonar.jdbc.username&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;sonar.jdbc.password&amp;gt;sonar&amp;lt;/sonar.jdbc.password&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;sonar.host.url&amp;gt;http://localhost:9000&amp;lt;/sonar.host.url&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/properties&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/profile&amp;gt;&lt;br /&gt;&amp;lt;/profiles&amp;gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-2697094084995131040?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/2697094084995131040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=2697094084995131040' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/2697094084995131040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/2697094084995131040'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2011/09/solution-sql-driver-not-found.html' title='SOLUTION: &quot;SQL driver not found org.apache.derby.jdbc.ClientDriver&quot; When Using Oracle with Sonar and Maven'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-6158328009656146978</id><published>2011-09-06T12:42:00.000-05:00</published><updated>2011-09-09T10:25:09.340-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='PMD'/><title type='text'>SOLUTION: Modify PMD's ShortVariable Rule To Ignore ID Fields</title><content type='html'>&lt;p&gt;Several people online have asked about the problem of not being able to add exceptions to PMD's ShortVariable rule. Most often, it has been the desire to get PMD to ignore the case where the variable name is 'id'. I was not able to find a solution online, but I worked with the XPath until I came up with a working solution.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;In Eclipse, go to Window » Preferences » PMD » Rules configuration » ShortVariable » Edit Rule...&lt;/li&gt;&lt;li&gt;Change the XPath field to:&lt;div style="background: #eee; border: 1px solid black; color: black; font-family: Courier New,Courier,monospace; margin: 5px; padding: 5px; text-align: left;"&gt;//VariableDeclaratorId[(string-length(@Image) &lt; 3) &lt;strong&gt;and (not (@Image='id'))&lt;/strong&gt;]&lt;br /&gt; [not(ancestor::ForInit)]&lt;br /&gt; [not((ancestor::FormalParameter) and (ancestor::TryStatement))]&lt;/div&gt;&lt;/li&gt;&lt;li&gt;Click Apply » Confirm rebuild » Click Ok » Confirm rebuild&lt;/li&gt;&lt;li&gt;Restart Eclipse&lt;/li&gt;&lt;li&gt;Right-click on the project » PMD » Check code with PMD&lt;/li&gt;&lt;ol&gt;&lt;p&gt;You should then see the warning markers disappear on your id fields.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-6158328009656146978?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/6158328009656146978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=6158328009656146978' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/6158328009656146978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/6158328009656146978'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2011/09/solution-modify-pmds-shortvariable-rule.html' title='SOLUTION: Modify PMD&apos;s ShortVariable Rule To Ignore ID Fields'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-8635944145735533428</id><published>2009-12-19T10:59:00.006-05:00</published><updated>2009-12-19T11:35:23.570-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Can is_string() be used without an isset() for unset variables in PHP?</title><content type='html'>&lt;h2&gt;The Short Answer&lt;/h2&gt;&lt;br /&gt;Yes, if there is the potential for an undeclared variable to be passed to functions like is_string(), then you must use the isset() function first.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;if(isset($foo)&amp;nbsp;&amp;&amp;&amp;nbsp;is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; // Do something with $foo&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;The Long Answer&lt;/h2&gt;&lt;br /&gt;I recently had an error occur in a 3rd party function I use on my web site. The code assumed that at a certain point that a variable would be set and a string function could be run against it. I wanted to modify the if statement to check to see if the variable was a string before continuing with the said block of code. What I did not know was whether or not the is_string function in PHP worked in the same way as the instanceOf operator in Java. In Java, you do not need to detect if the variable is null before the operation, because instanceOf has the built in ability to determine that a null is not an instance of anything.&lt;br /&gt;&lt;br /&gt;The reason I wanted to test this is because the error resulted after a customer interaction with the site that I am not able to reproduce (this is intentional, because it involves translating a user's file, which I do not keep a copy of in accordance with my privacy statement).&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Example Code&lt;/h2&gt;&lt;br /&gt;To test this I wrote a PHP page to determines what happens when a variable is in different states. I also expanded the testing to include is_array, is_bool, is_float, is_int, and is_object. I also include some custom error handling, so you can try this at home without filling up your error log.&lt;br /&gt;&lt;br /&gt;To see this in action: &lt;a href="http://www.threeleaf.com/freelance-work/demos/is_string.php"&gt;Using is_string() and isset() Demo&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&amp;lt;?php &lt;br /&gt;/* we will do our own error handling */&lt;br /&gt;function jamErrorHandler($errno, $errmsg, $filename, $linenum, $vars) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $errortype = array (&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_ERROR             =&amp;gt; 'Error',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_WARNING           =&amp;gt; 'Warning',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_PARSE             =&amp;gt; 'Parsing Error',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_NOTICE            =&amp;gt; 'Notice',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_CORE_ERROR        =&amp;gt; 'Core Error',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_CORE_WARNING      =&amp;gt; 'Core Warning',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_COMPILE_ERROR     =&amp;gt; 'Compile Error',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_COMPILE_WARNING   =&amp;gt; 'Compile Warning',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_USER_ERROR        =&amp;gt; 'User Error',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_USER_WARNING      =&amp;gt; 'User Warning',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_USER_NOTICE       =&amp;gt; 'User Notice',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_ALL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; =&amp;gt; 'All Error',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_STRICT     &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; =&amp;gt; 'Strict Error',&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E_RECOVERABLE_ERROR&amp;nbsp; &amp;nbsp; =&amp;gt; 'Recoverable Error'&lt;br /&gt;&amp;nbsp; &amp;nbsp; );&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;* ' . $errortype[$errno] . ': ' . $errmsg . ' *&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;function jamExceptionHandler($exception){&lt;br /&gt;&amp;nbsp; &amp;nbsp; jamErrorHandler($exception-&amp;gt;getCode(), $exception-&amp;gt;getMessage(), $exception-&amp;gt;getFile(), $exception-&amp;gt;getLine(), $exception-&amp;gt;getTrace());&lt;br /&gt;}&lt;br /&gt;set_error_handler('jamErrorHandler');&lt;br /&gt;set_exception_handler('jamExceptionHandler');&lt;br /&gt;print '&amp;lt;h2&amp;gt;$foo = 123&amp;lt;/h2&amp;gt;';&lt;br /&gt;$foo = 123;&lt;br /&gt;if(isset($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is set.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not set.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(isset($foo) &amp;&amp; is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo isset and is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(isset($foo)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo isset, but is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo is not set, so is not string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;if(is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_float($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a float.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a float.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_int($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an integer.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an integer.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_bool($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a boolean.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a boolean.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_object($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an object.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an object.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_array($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an array.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an array.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;print '&amp;lt;h2&amp;gt;$foo = 123.456&amp;lt;/h2&amp;gt;';&lt;br /&gt;$foo = 123.456;&lt;br /&gt;if(isset($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is set.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not set.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(isset($foo) &amp;&amp; is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo isset and is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(isset($foo)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo isset, but is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo is not set, so is not string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;if(is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_float($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a float.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a float.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_int($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an integer.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an integer.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_bool($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a boolean.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a boolean.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_object($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an object.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an object.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_array($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an array.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an array.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;print '&amp;lt;h2&amp;gt;$foo = \'123\'&amp;lt;/h2&amp;gt;';&lt;br /&gt;$foo = '123';&lt;br /&gt;if(isset($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is set.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not set.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(isset($foo) &amp;&amp; is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo isset and is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(isset($foo)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo isset, but is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo is not set, so is not string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;if(is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_float($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a float.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a float.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_int($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an integer.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an integer.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_bool($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a boolean.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a boolean.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_object($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an object.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an object.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_array($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an array.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an array.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;print '&amp;lt;h2&amp;gt;$foo = \'abc\'&amp;lt;/h2&amp;gt;';&lt;br /&gt;$foo = 'abc';&lt;br /&gt;if(isset($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is set.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not set.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(isset($foo) &amp;&amp; is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo isset and is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(isset($foo)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo isset, but is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo is not set, so is not string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;if(is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_float($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a float.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a float.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_int($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an integer.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an integer.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_bool($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a boolean.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a boolean.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_object($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an object.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an object.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_array($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an array.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an array.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;print '&amp;lt;h2&amp;gt;$foo = date(\'r\')&amp;lt;/h2&amp;gt;';&lt;br /&gt;$foo = date('r');&lt;br /&gt;if(isset($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is set.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not set.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(isset($foo) &amp;&amp; is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo isset and is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(isset($foo)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo isset, but is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo is not set, so is not string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;if(is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_float($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a float.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a float.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_int($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an integer.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an integer.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_bool($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a boolean.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a boolean.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_object($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an object.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an object.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_array($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an array.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an array.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;print '&amp;lt;h2&amp;gt;$foo = true&amp;lt;/h2&amp;gt;';&lt;br /&gt;$foo = true;&lt;br /&gt;if(isset($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is set.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not set.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(isset($foo) &amp;&amp; is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo isset and is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(isset($foo)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo isset, but is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo is not set, so is not string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;if(is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_float($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a float.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a float.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_int($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an integer.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an integer.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_bool($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a boolean.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a boolean.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_object($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an object.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an object.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_array($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an array.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an array.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;print '&amp;lt;h2&amp;gt;$foo = false&amp;lt;/h2&amp;gt;';&lt;br /&gt;$foo = false;&lt;br /&gt;if(isset($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is set.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not set.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(isset($foo) &amp;&amp; is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo isset and is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(isset($foo)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo isset, but is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo is not set, so is not string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;if(is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_float($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a float.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a float.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_int($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an integer.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an integer.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_bool($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a boolean.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a boolean.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_object($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an object.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an object.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_array($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an array.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an array.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;print '&amp;lt;h2&amp;gt;$foo = array(\'1\', \'a\')&amp;lt;/h2&amp;gt;';&lt;br /&gt;$foo = array('1', 'a');&lt;br /&gt;if(isset($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is set.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not set.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(isset($foo) &amp;&amp; is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo isset and is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(isset($foo)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo isset, but is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo is not set, so is not string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;if(is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_float($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a float.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a float.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_int($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an integer.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an integer.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_bool($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a boolean.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a boolean.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_object($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an object.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an object.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_array($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an array.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an array.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;print '&amp;lt;h2&amp;gt;$foo = jamObject()&amp;lt;/h2&amp;gt;';&lt;br /&gt;class jamObject {&lt;br /&gt;    function test() {&lt;br /&gt;        print 'test';&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;$foo = new jamObject();&lt;br /&gt;if(isset($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is set.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not set.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(isset($foo) &amp;&amp; is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo isset and is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(isset($foo)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo isset, but is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo is not set, so is not string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;if(is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_float($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a float.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a float.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_int($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an integer.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an integer.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_bool($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a boolean.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a boolean.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_object($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an object.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an object.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_array($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an array.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an array.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;print '&amp;lt;h2&amp;gt;unset($foo)&amp;lt;/h2&amp;gt;';&lt;br /&gt;unset($foo);&lt;br /&gt;if(isset($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is set.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not set.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(isset($foo) &amp;&amp; is_string($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo isset and is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(isset($foo)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo isset, but is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo is not set, so is not string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;try {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(is_string($foo)) { // Produces error!&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a string.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print '$foo is not a string.&amp;lt;br /&amp;gt;';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;} catch (Exception $e) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;Error in is_string($foo)&amp;lt;/strong&amp;gt;' . $e-&amp;gt;getMessage() . '&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_float($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a float.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a float.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_int($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an integer.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an integer.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_bool($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is a boolean.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not a boolean.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_object($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an object.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an object.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;if(is_array($foo)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '&amp;lt;strong&amp;gt;$foo is an array.&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; print '$foo is not an array.&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-8635944145735533428?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/8635944145735533428/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=8635944145735533428' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/8635944145735533428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/8635944145735533428'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2009/12/can-isstring-be-used-without-isset-for.html' title='Can is_string() be used without an isset() for unset variables in PHP?'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-9039888045623283927</id><published>2009-03-06T21:14:00.002-05:00</published><updated>2009-03-06T23:04:10.986-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Facebook'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>ELIZA, the Computer Therapist Facebook application</title><content type='html'>I have converted the classic (read: old) ELIZA application to run on Facebook. ELIZA is a Rogerian therapist parody originally written by Joseph Weizenbaum. This application is for entertainment purposes only. ELIZA is not human and is not a real therapist. If you have a session with ELIZA that you think was amusing or thought provoking, you can publish it on your profile.&lt;br /&gt;&lt;br /&gt;Please give it a try at:&lt;br /&gt;&lt;a href="http://apps.facebook.com/eliza-therapist/"&gt;http://apps.facebook.com/eliza-therapist/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I would appreciate your feedback.&lt;br /&gt;&lt;br /&gt;This is my first Facebook application. I have ideas for two more at the moment, but they are going to take more work than this one... I wanted to start with something simple :-).&lt;br /&gt;&lt;br /&gt;If you are not on Facebook, I have also made an online version at ThreeLeaf.com:&lt;br /&gt;&lt;a href="http://www.threeleaf.com/freelance-work/demos/eliza/"&gt;http://www.threeleaf.com/freelance-work/demos/eliza/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;br /&gt;John&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-9039888045623283927?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/9039888045623283927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=9039888045623283927' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/9039888045623283927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/9039888045623283927'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2009/03/eliza-computer-therapist-facebook.html' title='ELIZA, the Computer Therapist Facebook application'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-5308056858110396180</id><published>2008-10-02T07:26:00.000-05:00</published><updated>2008-10-02T07:27:21.944-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='computers'/><category scheme='http://www.blogger.com/atom/ns#' term='customer service'/><category scheme='http://www.blogger.com/atom/ns#' term='review'/><title type='text'>Gateway Extended Warranty... Definitely a Waste of Money… Maybe the Computer Too</title><content type='html'>This falls into the category of "you should have known better." My first experience with a Gateway computer was as a graduate student at the University of Wyoming. The first thing I heard about these computers is that the motherboard had a design flaw, which resulted in the CPU occasionally popping out of its socket. Someone would then have to open the case and reseat it whenever this happened. I worked with a lot of Gateway computers as a PC technician at Research Triangle Institute. During my 3 year tenure in that position, RTI signed a purchase agreement with Gateway, and I received, installed, and repaired approximately 200 Gateway computers during that time. I do not have an exact count, but I am pretty sure nearly every one of those units needed repair at some point during that short period of time. The worse case was a batch of 26 computers whose hard drives all gave out within 4 months of being received.&lt;br /&gt;&lt;br /&gt;Many years later, in 2005, I am looking at purchasing a new computer. I included Gateway in my list of options despite my past experiences with them, hoping that they may have finally learned to build reliable computers despite their long history of poor quality. When it came to decision time, Gateway was one of my final two contenders. I ended up going with Gateway because they offered more features for a lower price (not inexpensive... this was one of their top-of-the-line PCs). I purposely purchased the four year extended warranty, hedging my bet that if I did have problems, the PC would be covered. The customer service while I was at RTI typically was typically good, and they would often ship replacement parts to me within 2-3 business days, and after I had replaced them, I could send the old parts back. I am not naïve enough to think that "regular" customers would get the same level of support as corporate customers, but I was really unprepared for what my situation would be.&lt;br /&gt;&lt;br /&gt;In June of this year (2008), the PC suddenly stopped working. It would not boot. It would not even POST. It was dead as a doornail with no apparent cause. After running through the online support tests, I eventually determined that it had to be a motherboard problem. Not a problem, I thought, I will put in a service request and get this fixed up. My first issue became what the four-year warranty actually covered. I was certain that I had purchased on-site service. My first several correspondents ranged from "your warranty expired" to "it only covers parts" to "even if you had on-site service, they would only replace the part, service representatives do not visit to diagnose the problem." My online receipt has a cryptic entry for the four year warranty, so it is quite possible that it does only cover replacement. The service people I corresponded with said I should check my receipt or order a replacement receipt. Unfortunately, even though I have all my manuals, I could not find my receipt for some reason. I did order a replacement, which involves both an online order form and an e-mail confirmation, but I did not receive a receipt, though it does not appear that they charged my card either. Good grief! It is hard for me to understand why a simple process that has a manual customer service follow-up can still fail.&lt;br /&gt;&lt;br /&gt;Ok, so by this time I have been without my PC for about 3 weeks bickering with Gateway over the warranty and receipt. I decide it is not worth the hassle anymore. I purchased their $67 pre-paid shipping box (miraculously, that order went through) and sent my computer off. On August 8, I got a confirmation e-mail that Gateway received my PC, and I should expect a 3-5 day turnaround.&lt;br /&gt;&lt;br /&gt;So I wait.&lt;br /&gt;&lt;br /&gt;And wait.&lt;br /&gt;&lt;br /&gt;Finally, after two weeks, I send in an e-mail asking for a status report. I get a message back indicating that they determined it was indeed a motherboard problem, and they did not have the part in stock, but it had been ordered. The computer should be ready in 3-5 more days.&lt;br /&gt;&lt;br /&gt;So I wait.&lt;br /&gt;&lt;br /&gt;After a week with no communication, I write again. Again, I am told that the repair is taking longer than expected, but it should be shipped in a couple of days.&lt;br /&gt;&lt;br /&gt;So I wait.&lt;br /&gt;&lt;br /&gt;After another week, I am pretty unhappy that I have no computer, and had no communication. I sent a more terse e-mail asking for an update and some kind of immediate solution, like an equivalent replacement. My request was returned with a profuse apology about the delay, and an assurance that they were doing everything they could. However, that obviously did not include a replacement or a loaner.&lt;br /&gt;&lt;br /&gt;So I wait.&lt;br /&gt;&lt;br /&gt;Again, after another week I send another exasperated e-mail in, requesting action, and a phone number where I can call someone. I received a reply simply stating that they were working on it. No phone number, of course.&lt;br /&gt;&lt;br /&gt;So I wait.&lt;br /&gt;&lt;br /&gt;Finally! A communication arrived that I did not have to initiate! They said they had finished the repair on my &lt;em&gt;laptop&lt;/em&gt;, but needed my permission to wipe the hard drive to reinstall the operating system. I replied that I had sent in a &lt;em&gt;PC&lt;/em&gt;, not a laptop, but if they were talking about the PC then yes, of course they could reinstall the operating system (I had actually sent it in with a blank drive, because I cannot lose what is on the hard drive). About three days later I get an e-mail stating that they were finished and were shipping the PC back to me. I should receive it in 3-5 days, unless I had purchased the gold plan, in which case I would receive it in one day (I do not think I had the gold plan, but I could wait 5 days if needed, and in my opinion it was pointless to include that note since it would have been too late to purchase it anyway) Hurray! … Or so I thought.&lt;br /&gt;&lt;br /&gt;So I wait.&lt;br /&gt;&lt;br /&gt;After another week goes by I send in a request for the tracking number, since I had not yet received the PC. They responded saying that the package had been received and included the tracking number. I go to the FedEx site and find that the destination was Temple, TX (I live in NC). So, I wrote back and said that they had shipped it to the wrong address, and that they needed to either recover the PC or send me an equivalent. I get a response back that the PC needed more repairs and was shipped to Temple, TX, where they contract out repairs. Actually, they said it was still "in transit," indicating to me that the really had no idea where the PC was.&lt;br /&gt;&lt;br /&gt;So I wait.&lt;br /&gt;&lt;br /&gt;It has now been another week since my last e-mail, and I am about to e-mail them again for a status update. I have no idea if Gateway really knows where my PC is, what state of repair it is in, nor do I know if I will ever get my PC or a replacement.&lt;br /&gt;&lt;br /&gt;I have reminded them in several of my e-mails that I paid a lot for the PC and more for the extended warranty, but except for the one apologetic message, I have received no sympathy and no action to help resolve the problems. This level of service is completely abominable, and unacceptable. It certainly seems to me that if you purchase a four-year warranty that there is a built-in expectation that the seller would have some plan to deal with any and all repairs during that timeframe, even if it is just to send an equivalent computer back (I suspect an equivalent replacement today costs less than the price I paid for the warranty).&lt;br /&gt;&lt;br /&gt;I am posting this blog entry so that my friends, family, and readers will reconsider any thoughts they might have of purchasing Gateway computers. As I stated at the beginning, I should have known better, but I will never make that mistake again, and I hope my readers will not either.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-5308056858110396180?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/5308056858110396180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=5308056858110396180' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/5308056858110396180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/5308056858110396180'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2008/10/gateway-extended-warranty-definitely.html' title='Gateway Extended Warranty... Definitely a Waste of Money… Maybe the Computer Too'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-1631041269080179174</id><published>2008-01-25T22:16:00.000-05:00</published><updated>2008-01-25T22:24:53.335-05:00</updated><title type='text'>The onContextMenu Event Handler</title><content type='html'>&lt;h2&gt;onContextMenu event does not fire on disabled fields&lt;/h2&gt;&lt;br /&gt; &lt;p&gt;The onContextMenu event (right-click in Windows) is a proprietary handler in HTML, but is very useful for displaying custom context menus on web pages. For this particular article, I was investigating an application where the business owner wanted a context menu available on disabled fields. The problem specifically occurs because all click events are apparently ignored on disabled fields. Note that Opera apparently ignores the onContextMenu event completely, because it is not a W3C compliant attribute.&lt;/p&gt;&lt;br /&gt; &lt;p&gt;Regardless of the W3C non-compliance, the business still wanted this behavior (as far as we know everyone is using IE or FF). Try the following in your browser to see how it behaves.&lt;/p&gt;&lt;br /&gt; &lt;form onsubmit="return false;" action="#"&gt;&lt;br /&gt;  &lt;div class="form-row"&gt;&lt;br /&gt;   &lt;label for="input1"&gt;Enabled Input Field&lt;/label&gt;&lt;br /&gt;   &lt;input id="input1" type="text" value="input1" oncontextmenu="alert('input1');return false;" /&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;  &lt;div class="form-row"&gt;&lt;br /&gt;   &lt;label for="input2"&gt;Disabled Input Field&lt;/label&gt;&lt;br /&gt;   &lt;input id="input2" type="text" value="input2" disabled="disabled" oncontextmenu="alert('input2');return false;" /&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt; &lt;/form&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;input id=&amp;quot;input1&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;input1&amp;quot; oncontextmenu=&amp;quot;alert('input1');return false;&amp;quot; /&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt; &lt;h2&gt;Attempt 1: Nest it in a div&lt;/h2&gt;&lt;br /&gt; &lt;p&gt;The first thing we tried was to wrap the input fields in a div element that had an onContextMenu attribute defined. We found that while this solved the problem in IE7, FF did not &amp;quot;bubble up&amp;quot; the event through the disabled input field. However, any text inside the div element did respond to the onContextMenu event. Try the following in your browser to see how it behaves.&lt;/p&gt;&lt;br /&gt; &lt;form onsubmit="return false;" action="#"&gt;&lt;br /&gt;  &lt;div class="form-row"&gt;&lt;br /&gt;   &lt;label for="input3"&gt;Enabled Input Field Wrapped With A Div&lt;/label&gt;&lt;br /&gt;   &lt;div oncontextmenu="alert('input3');return false;"&gt;Inside div, outside input3 field &lt;br /&gt;    &lt;input id="input3" type="text" value="input3" /&gt;&lt;br /&gt;   &lt;/div&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;  &lt;div class="form-row"&gt;&lt;br /&gt;   &lt;label for="input4"&gt;Disabled Input Field Wrapped With A Div&lt;/label&gt;&lt;br /&gt;   &lt;div oncontextmenu="alert('input4');return false;"&gt;Inside div, outside input4 field &lt;br /&gt;    &lt;input id="input4" type="text" value="input4" disabled="disabled" /&gt;&lt;br /&gt;   &lt;/div&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt; &lt;/form&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;div oncontextmenu=&amp;quot;alert('input3');return false;&amp;quot;&amp;gt;Inside div, outside input3 field &lt;br /&gt;&lt;br /&gt; &amp;lt;input id=&amp;quot;input3&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;input3&amp;quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt; &lt;h2&gt;Solution 1: Convert from disabled to read-only&lt;/h2&gt;&lt;br /&gt; &lt;p&gt;After a little more research, I found another attribute named &amp;quot;readonly&amp;quot; that I had not used before. I tried it, and found that the onContextMenu event worked just fine in both IE7 and FF.&lt;/p&gt; &lt;br /&gt; &lt;form onsubmit="return false;" action="#"&gt;&lt;br /&gt;  &lt;div class="form-row"&gt;&lt;br /&gt;   &lt;label for="input5"&gt;Read-only Input Field&lt;/label&gt;&lt;br /&gt;   &lt;input id="input5" type="text" value="input5" readonly="readonly" oncontextmenu="alert('input5');return false;" /&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;  &lt;div class="form-row"&gt;&lt;br /&gt;   &lt;label for="input6"&gt;Read-only Input Field Wrapped With A Div&lt;/label&gt;&lt;br /&gt;   &lt;div oncontextmenu="alert('input6');return false;"&gt;Inside div, outside input6 field &lt;br /&gt;    &lt;input id="input6" type="text" value="input6" readonly="readonly" /&gt;&lt;br /&gt;   &lt;/div&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt; &lt;/form&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;input id=&amp;quot;input5&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;input5&amp;quot; readonly=&amp;quot;readonly&amp;quot; oncontextmenu=&amp;quot;alert('input5');return false;&amp;quot; /&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt; &lt;h2&gt;Solution 2: Make an external, clickable object&lt;/h2&gt;&lt;br /&gt; &lt;p&gt;I definitely prefer W3C compliant code, however, so a compliant solution would have to involve an external, clickable element to trigger the event. The &amp;raquo; symbol below has an onClick event, which works in IE, FF, and Opera.&lt;/p&gt;&lt;br /&gt; &lt;form onsubmit="return false;" action="#"&gt;&lt;br /&gt;  &lt;div class="form-row"&gt;&lt;br /&gt;   &lt;label for="input7"&gt;Clickable symbol&lt;/label&gt;&lt;br /&gt;   &lt;input id="input7" type="text" value="input7" disabled="disabled" /&gt; &lt;span onclick="alert('input7');return false;" style="cursor:pointer;"&gt;&amp;raquo;&lt;/span&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt; &lt;/form&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;input id=&amp;quot;input7&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;input7&amp;quot; disabled=&amp;quot;disabled&amp;quot; /&amp;gt; &amp;lt;span onclick=&amp;quot;alert('input7');return false;&amp;quot; style=&amp;quot;cursor:pointer;&amp;quot;&amp;gt;&amp;amp;raquo;&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt; &lt;p&gt;There are some accessibility issues with this approach, of course. One might want to use a link instead of a span to underline the clickable element or choose a more obvious graphical symbol. There are other inherent accessibility issues with the entire context menu approach, but I will not go into those here.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-1631041269080179174?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/1631041269080179174/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=1631041269080179174' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/1631041269080179174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/1631041269080179174'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2008/01/oncontextmenu-event-handler.html' title='The onContextMenu Event Handler'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-8376112183390915142</id><published>2007-04-04T15:14:00.000-05:00</published><updated>2007-11-14T11:20:29.820-05:00</updated><title type='text'>Zip Code Distances</title><content type='html'>&lt;p&gt;I am currently involved in a project where the program I am writing is supposed to return a list of the 10 doctors nearest to a visitor's zip code. Note that this is not the same as doctors in a given radius (say 10 miles), but it does use the same basic formula. This article will be the first of a two part series and lays the groundwork for calculating what is nearest to a zip code. In the second part I intend to show how I integrate this logic with a list of doctors with addresses.&lt;/p&gt;&lt;p&gt;Below you will find the results of my experimental queries that compare the classic radius methodology with my own "10 nearest" methodology. My production program uses a UDB (DB2) database, and I thought of the performance contrasts between UDB and MySQL was interesting, so I am going to show all the comparisons below. Finally, I wanted to show what differences there were between the more accurate "Haversine Formula" as compared to the less intensive "Spherical Law of Cosines" when calculating the distance between two points on a sphere. These examples should give you plenty of real life code you can use in your own programs.&lt;/p&gt;The company I work for subscribes to the zip code database (referred to here as ZipUSA) from &lt;a href="http://www.zipdatafiles.com/data/"&gt;http://www.zipdatafiles.com/data/&lt;/a&gt; The data comes from the United States Postal Service and other sources, but I have occasionally found strange geocoding results. I will probably write a different article about that using a different application that I have written.&lt;br /&gt;&lt;h3&gt;&lt;a name="within_10_miles" id="within_10_miles"&gt;Within 10 miles&lt;/a&gt;&lt;/h3&gt;&lt;h4&gt;&lt;a name="haversine_formula" id="haversine_formula"&gt;Haversine Formula&lt;/a&gt;&lt;br /&gt;&lt;/h4&gt; &lt;div class="level4"&gt;&lt;p&gt;The following finds the zip codes within 10 miles of 27712 using the haversine (great circle) equation. The field names are based on the ZipUSA tables.&lt;/p&gt;&lt;pre class="code sql"&gt;&lt;span class="kw1"&gt;SELECT&lt;/span&gt; &lt;span class="kw1"&gt;DISTINCT&lt;/span&gt;&lt;br /&gt;destination.zip_code,&lt;br /&gt;&lt;span class="nu0"&gt;3956&lt;/span&gt; * &lt;span class="nu0"&gt;2&lt;/span&gt; * ASIN&lt;span class="br0"&gt;(&lt;/span&gt;SQRT&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat - destination.lat&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lng - destination.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; distance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;FROM&lt;/span&gt;&lt;br /&gt;tblZipUSA origin,&lt;br /&gt;tblZipUSA destination&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;WHERE&lt;/span&gt;&lt;br /&gt;origin.zip_code = &lt;span class="st0"&gt;'27712'&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;AND&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;3956&lt;/span&gt; * &lt;span class="nu0"&gt;2&lt;/span&gt; * ASIN&lt;span class="br0"&gt;(&lt;/span&gt;SQRT&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat - destination.lat&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lng - destination.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; &amp;lt; &lt;span class="nu0"&gt;10&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;ORDER&lt;/span&gt; &lt;span class="kw1"&gt;BY&lt;/span&gt;&lt;br /&gt;distance, zip_code&lt;/pre&gt; &lt;/div&gt; &lt;p&gt;The ZipUSA database was set up with the same indexes in MySQL and UDB (DB2). Queries in MySQL were run in the phpAdmin tool. The UDB/DB2 queries were run in Quest.&lt;/p&gt;&lt;br /&gt;&lt;h5&gt;&lt;a name="mysql1" id="mysql1"&gt;MySQL&lt;/a&gt;  &lt;/h5&gt; &lt;div class="level5"&gt;&lt;table class="inline"&gt;   &lt;tbody&gt;&lt;tr&gt;    &lt;th&gt;zip_code&lt;/th&gt;&lt;br /&gt;   &lt;th&gt;distance&lt;/th&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27712&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;0&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27704&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;4.75326962990057&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27705&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.34287681627437&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27708&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.57383981806715&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27503&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.58564401941337&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27701&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.41245709075393&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27706&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.58029004252293&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27709&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.59449266010451&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27702&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27710&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27711&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27715&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27717&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27722&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27707&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;8.57121741472298&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27703&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.5828790270889&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27278&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.58552637370736&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27564&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.72570727493623&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27509&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.80777888765073&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;Showing rows 0 - 18 (19 total, Query took 2.1139 sec)&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h5&gt;&lt;a name="db2_udb" id="db2_udb"&gt;DB2/UDB&lt;/a&gt;&lt;/h5&gt;&lt;br /&gt;&lt;div class="level5"&gt;&lt;br /&gt; &lt;table class="inline"&gt;&lt;br /&gt;  &lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;   &lt;th&gt;zip_code&lt;/th&gt;&lt;br /&gt;   &lt;th&gt;distance&lt;/th&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27712&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;0&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27704&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;4.75326962990023&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27705&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.34287681627435&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27708&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.57383981806714&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27503&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.58564401941335&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27701&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.41245709075397&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27706&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.58029004252301&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27709&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.5944926601046&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27702&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445641&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27710&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445641&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27711&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445641&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27715&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445641&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27717&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445641&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27722&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445641&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27707&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;8.571217414723011&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27703&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.582879027088699&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27278&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.58552637370768&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27564&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.725707274936291&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27509&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.80777888765007&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;19 rows selected in 35.77 secs.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;I was very shocked to have such a slow run time in UDB! I was expecting better performance from a corporate-level product. I also went back and checked all the indexes to verify they were on the same fields as were in my MySQL database. I do not have enough knowledge about UDB to explain why this disparity exists or how one might optimize the query to run better on this platform. I would not think one should have to do that.&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h4&gt;&lt;a name="spherical_law_of_cosines" id="spherical_law_of_cosines"&gt;Spherical Law of Cosines&lt;/a&gt;&lt;/h4&gt;&lt;br /&gt;&lt;div class="level4"&gt;&lt;br /&gt;&lt;pre class="code sql"&gt;&lt;span class="kw1"&gt;SELECT&lt;/span&gt; &lt;span class="kw1"&gt;DISTINCT&lt;/span&gt;&lt;br /&gt;destination.zip_code,&lt;br /&gt;&lt;span class="nu0"&gt;3956&lt;/span&gt; * ACOS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt; SIN&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * SIN&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * COS&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;destination.lng - origin.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt; &lt;span class="kw1"&gt;AS&lt;/span&gt; distance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;FROM&lt;/span&gt;&lt;br /&gt;tblZipUSA origin,&lt;br /&gt;tblZipUSA destination&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;WHERE&lt;/span&gt;&lt;br /&gt;origin.zip_code = &lt;span class="st0"&gt;'27712'&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;AND&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;3956&lt;/span&gt; * ACOS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt; SIN&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * SIN&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * COS&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;destination.lng - origin.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt; &amp;lt; &lt;span class="nu0"&gt;10&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;ORDER&lt;/span&gt; &lt;span class="kw1"&gt;BY&lt;/span&gt;&lt;br /&gt;distance, zip_code&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h5&gt;&lt;a name="mysql2" id="mysql2"&gt;MySQL&lt;/a&gt;&lt;/h5&gt;&lt;br /&gt;&lt;div class="level5"&gt;&lt;br /&gt; &lt;table class="inline"&gt;&lt;br /&gt;  &lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;   &lt;th&gt;zip_code&lt;/th&gt;&lt;br /&gt;   &lt;th&gt;distance&lt;/th&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27712&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;0&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27704&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;4.75326963012033&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27705&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.34287681651191&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27708&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.57383981817397&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27503&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.58564401945863&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27701&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.41245709087189&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27706&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.58029004273494&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27709&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.59449266019943&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27702&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27710&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27711&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27715&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27717&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27722&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27707&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;8.57121741478871&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27703&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.58287902708428&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27278&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.58552637385399&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27564&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.72570727482013&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27509&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.80777888768795&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;Showing rows 0 - 18 (19 total, Query took 1.9229 sec)&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h5&gt;&lt;a name="db2_udb1" id="db2_udb1"&gt;DB2/UDB&lt;/a&gt;&lt;/h5&gt;&lt;br /&gt;&lt;div class="level5"&gt;&lt;br /&gt; &lt;table class="inline"&gt;&lt;br /&gt;  &lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;   &lt;th&gt;zip_code&lt;/th&gt;&lt;br /&gt;   &lt;th&gt;distance&lt;/th&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27712&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;0&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27704&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;4.75326963012037&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27705&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.3428768165119&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27708&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.57383981817396&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27503&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.58564401945862&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27701&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.41245709087191&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27706&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.58029004247087&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27709&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.59449266019946&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27702&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916438409&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27710&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916438409&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27711&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916438409&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27715&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916438409&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27717&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916438409&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27722&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916438409&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27707&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;8.571217414991439&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27703&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.58287902726561&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27278&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.58552637385398&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27564&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.72570727482014&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27509&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.807778887510789&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;19 rows selected in 11.05 secs.&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;It is obvious that using the Spherical Law of Cosines equation is much faster than the Haversine Formula. MySQL shows a 5% improvement in speed and UDB shows a 53% performance improvement. It is also obvious that the distances calculated are very close. For these mile calculations, the first seven decimal places are the same. In most applications I have seen, the miles are rounded off to two decimal places, meaning that there is no reason to use the Haversine formula for distances as far apart as most "centers of zip codes" are. Haversine calculations are more suited to much closer calculations. Also, since zip code to zip code distances are only used for approximate distances, it would not make sense to nit-pick over the only-so-slightly more accurate results the Haversine formula gives. And even beyond that, accuracy depends a lot on the latitude and longitude data supplied. I have found that different sources have different geocoding information concerning the geographic center of zip codes.&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;&lt;a name="th_closest" id="th_closest"&gt;10th closest&lt;/a&gt;&lt;/h3&gt;&lt;br /&gt;&lt;div class="level3"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The next part of this experiment was to find the 10 nearest zip codes to the one given. The first step is finding out which zip ranks number 10. In this case it is simply a matter of choosing the 10th zip code from the list.&lt;/p&gt;&lt;br /&gt;&lt;h4&gt;&lt;a name="haversine_formula1" id="haversine_formula1"&gt;Haversine Formula&lt;/a&gt;&lt;/h4&gt;&lt;br /&gt;&lt;div class="level4"&gt;&lt;br /&gt;&lt;pre class="code sql"&gt;&lt;span class="kw1"&gt;SELECT&lt;/span&gt; &lt;span class="kw1"&gt;DISTINCT&lt;/span&gt;&lt;br /&gt;destination.zip_code,&lt;br /&gt;&lt;span class="nu0"&gt;3956&lt;/span&gt; * &lt;span class="nu0"&gt;2&lt;/span&gt; * ASIN&lt;span class="br0"&gt;(&lt;/span&gt;SQRT&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat - destination.lat&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lng - destination.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; distance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;FROM&lt;/span&gt;&lt;br /&gt;tblZipUSA origin,&lt;br /&gt;tblZipUSA destination&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;WHERE&lt;/span&gt;&lt;br /&gt;origin.zip_code = &lt;span class="st0"&gt;'27712'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;ORDER&lt;/span&gt; &lt;span class="kw1"&gt;BY&lt;/span&gt;&lt;br /&gt;distance, zip_code&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;LIMIT&lt;/span&gt; &lt;span class="nu0"&gt;10&lt;/span&gt;, &lt;span class="nu0"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt; &lt;table class="inline"&gt;&lt;br /&gt;  &lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;   &lt;th&gt;Zip Code&lt;/th&gt;&lt;br /&gt;   &lt;th&gt;Distance&lt;/th&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27711&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;Showing rows 0 - 0 (1 total, Query took 3.4441 sec)&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h4&gt;&lt;a name="spherical_law_of_cosines1" id="spherical_law_of_cosines1"&gt;Spherical Law of Cosines&lt;/a&gt;&lt;/h4&gt;&lt;br /&gt;&lt;div class="level4"&gt;&lt;br /&gt;&lt;pre class="code sql"&gt;&lt;span class="kw1"&gt;SELECT&lt;/span&gt; &lt;span class="kw1"&gt;DISTINCT&lt;/span&gt;&lt;br /&gt;destination.zip_code,&lt;br /&gt;&lt;span class="nu0"&gt;3956&lt;/span&gt; * ACOS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt; SIN&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * SIN&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * COS&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;destination.lng - origin.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt; &lt;span class="kw1"&gt;AS&lt;/span&gt; distance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;FROM&lt;/span&gt;&lt;br /&gt;tblZipUSA origin,&lt;br /&gt;tblZipUSA destination&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;WHERE&lt;/span&gt;&lt;br /&gt;origin.zip_code = &lt;span class="st0"&gt;'27712'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;ORDER&lt;/span&gt; &lt;span class="kw1"&gt;BY&lt;/span&gt;&lt;br /&gt;distance, zip_code&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;LIMIT&lt;/span&gt; &lt;span class="nu0"&gt;10&lt;/span&gt;, &lt;span class="nu0"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt; &lt;table class="inline"&gt;&lt;br /&gt;  &lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;   &lt;th&gt;zip_code&lt;/th&gt;&lt;br /&gt;   &lt;th&gt;distance&lt;/th&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27711&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;Showing rows 0 - 0 (1 total, Query took 3.1833 sec)&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h3&gt;&lt;a name="th_closest_without_po_box_zip_codes" id="th_closest_without_po_box_zip_codes"&gt;10th Closest Without PO Box Zip Codes&lt;/a&gt;&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;If you have a stiuation where you will be working only with street addresses and can eliminate the zip codes, there is some performance improvement. In the ZipUSA tables, this is accomplished by placing fac_cd and zip_class in the WHERE clause. However, I soon found that 1) some of our doctors are using P.O. Boxes, and 2) some small towns only have post offices with PO Boxes. I ended up not using that further past this experiment.&lt;/p&gt;&lt;br /&gt;&lt;div class="level3"&gt;&lt;br /&gt;&lt;pre class="code sql"&gt;&lt;span class="kw1"&gt;SELECT&lt;/span&gt; &lt;span class="kw1"&gt;DISTINCT&lt;/span&gt;&lt;br /&gt;destination.zip_code,&lt;br /&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="nu0"&gt;3956&lt;/span&gt; * &lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="nu0"&gt;2&lt;/span&gt; * ASIN&lt;span class="br0"&gt;(&lt;/span&gt;SQRT&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat-destination.lat&lt;span class="br0"&gt;)&lt;/span&gt;*&lt;span class="nu0"&gt;0.017453293&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;/&lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;,&lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat*&lt;span class="nu0"&gt;0.017453293&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat*&lt;span class="nu0"&gt;0.017453293&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lng-destination.lng&lt;span class="br0"&gt;)&lt;/span&gt;*&lt;span class="nu0"&gt;0.017453293&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;/&lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;,&lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; distance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;FROM&lt;/span&gt;&lt;br /&gt;tblZipUSA origin,&lt;br /&gt;tblZipUSA destination&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;WHERE&lt;/span&gt;&lt;br /&gt;origin.zip_code=&lt;span class="st0"&gt;'27712'&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;AND&lt;/span&gt; destination.fac_cd = &lt;span class="st0"&gt;'P'&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;AND&lt;/span&gt; destination.zip_class != &lt;span class="st0"&gt;'P'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;ORDER&lt;/span&gt; &lt;span class="kw1"&gt;BY&lt;/span&gt; distance&lt;br /&gt;&lt;span class="kw1"&gt;LIMIT&lt;/span&gt; &lt;span class="nu0"&gt;10&lt;/span&gt;,&lt;span class="nu0"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt; &lt;table class="inline"&gt;&lt;br /&gt;  &lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;   &lt;th&gt;Zip Code&lt;/th&gt;&lt;br /&gt;   &lt;th&gt;Distance&lt;/th&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27703&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;9.58287927196898&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;Showing rows 0 - 0 (1 total, Query took 2.4226 sec)&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h3&gt;&lt;a name="nearest_10" id="nearest_10"&gt;Nearest 10&lt;/a&gt;&lt;/h3&gt;&lt;br /&gt;&lt;div class="level3"&gt;&lt;br /&gt;&lt;p&gt;Now that we can find the 10th closest zip code, we can join the two types of queries together to find all the zip codes up to the closest 10th. As a pleasant side effect, if there is a tie for 10th place, all of those zip codes are included as well. This becomes particularly obvious in the case where several P.O. Box zip codes are served from the same post office, and thus have the same geocoding. Of course, it is possible that there will be two or more physically distinct zip codes that will be equidistant from a given reference zip code, but I can only imagine that would be a very rare case.&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h4&gt;&lt;a name="haversine_formula2" id="haversine_formula2"&gt;Haversine Formula&lt;/a&gt;&lt;/h4&gt;&lt;br /&gt;&lt;div class="level4"&gt;&lt;br /&gt;&lt;pre class="code sql"&gt;&lt;span class="kw1"&gt;SELECT&lt;/span&gt; &lt;span class="kw1"&gt;DISTINCT&lt;/span&gt;&lt;br /&gt;destination.zip_code,&lt;br /&gt;&lt;span class="nu0"&gt;3956&lt;/span&gt; * &lt;span class="nu0"&gt;2&lt;/span&gt; * ASIN&lt;span class="br0"&gt;(&lt;/span&gt;SQRT&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat - destination.lat&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lng - destination.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; distance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;FROM&lt;/span&gt;&lt;br /&gt;tblZipUSA origin,&lt;br /&gt;tblZipUSA destination,&lt;br /&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;SELECT&lt;/span&gt; &lt;span class="kw1"&gt;DISTINCT&lt;/span&gt;&lt;br /&gt; destination1.zip_code,&lt;br /&gt; &lt;span class="nu0"&gt;3956&lt;/span&gt; * &lt;span class="nu0"&gt;2&lt;/span&gt; * ASIN&lt;span class="br0"&gt;(&lt;/span&gt;SQRT&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt;  POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin1.lat - destination1.lat&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt;  COS&lt;span class="br0"&gt;(&lt;/span&gt;origin1.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt;  COS&lt;span class="br0"&gt;(&lt;/span&gt;destination1.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt;  POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin1.lng - destination1.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt; &lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; distance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;FROM&lt;/span&gt;&lt;br /&gt; tblZipUSA origin1,&lt;br /&gt; tblZipUSA destination1&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;WHERE&lt;/span&gt;&lt;br /&gt; origin1.zip_code = &lt;span class="st0"&gt;'27712'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;ORDER&lt;/span&gt; &lt;span class="kw1"&gt;BY&lt;/span&gt;&lt;br /&gt; distance, zip_code&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;LIMIT&lt;/span&gt; &lt;span class="nu0"&gt;10&lt;/span&gt;, &lt;span class="nu0"&gt;1&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt; zipDistance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;WHERE&lt;/span&gt;&lt;br /&gt;origin.zip_code = &lt;span class="st0"&gt;'27712'&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;AND&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;3956&lt;/span&gt; * &lt;span class="nu0"&gt;2&lt;/span&gt; * ASIN&lt;span class="br0"&gt;(&lt;/span&gt;SQRT&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat - destination.lat&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; POWER&lt;span class="br0"&gt;(&lt;/span&gt;SIN&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;origin.lng - destination.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt; / &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; &amp;lt;= zipDistance.distance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;ORDER&lt;/span&gt; &lt;span class="kw1"&gt;BY&lt;/span&gt;&lt;br /&gt;distance, zip_code&lt;/pre&gt;&lt;br /&gt; &lt;table class="inline"&gt;&lt;br /&gt;  &lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;   &lt;th&gt;zip_code&lt;/th&gt;&lt;br /&gt;   &lt;th&gt;distance&lt;/th&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27712&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;0&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27704&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;4.75326962990057&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27705&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.34287681627437&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27708&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.57383981806715&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27503&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.58564401941337&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27701&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.41245709075393&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27706&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.58029004252293&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27709&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.59449266010451&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27702&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27710&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27711&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27715&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27717&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27722&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916445661&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;Showing rows 0 - 13 (14 total, Query took 5.6745 sec)&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h4&gt;&lt;a name="spherical_law_of_cosines2" id="spherical_law_of_cosines2"&gt;Spherical Law of Cosines&lt;/a&gt;&lt;/h4&gt;&lt;br /&gt;&lt;div class="level4"&gt;&lt;br /&gt;&lt;pre class="code sql"&gt;&lt;span class="kw1"&gt;SELECT&lt;/span&gt; &lt;span class="kw1"&gt;DISTINCT&lt;/span&gt;&lt;br /&gt;destination.zip_code,&lt;br /&gt;&lt;span class="nu0"&gt;3956&lt;/span&gt; * ACOS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt; SIN&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * SIN&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * COS&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;destination.lng - origin.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt; &lt;span class="kw1"&gt;AS&lt;/span&gt; distance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;FROM&lt;/span&gt;&lt;br /&gt;tblZipUSA origin,&lt;br /&gt;tblZipUSA destination,&lt;br /&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;SELECT&lt;/span&gt; &lt;span class="kw1"&gt;DISTINCT&lt;/span&gt;&lt;br /&gt; destination1.zip_code,&lt;br /&gt; &lt;span class="nu0"&gt;3956&lt;/span&gt; * ACOS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt;  SIN&lt;span class="br0"&gt;(&lt;/span&gt;origin1.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * SIN&lt;span class="br0"&gt;(&lt;/span&gt;destination1.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt;  COS&lt;span class="br0"&gt;(&lt;/span&gt;origin1.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * COS&lt;span class="br0"&gt;(&lt;/span&gt;destination1.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt;  COS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;destination1.lng - origin1.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt; &lt;span class="br0"&gt;)&lt;/span&gt; &lt;span class="kw1"&gt;AS&lt;/span&gt; distance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;FROM&lt;/span&gt;&lt;br /&gt; tblZipUSA origin1,&lt;br /&gt; tblZipUSA destination1&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;WHERE&lt;/span&gt;&lt;br /&gt; origin1.zip_code = &lt;span class="st0"&gt;'27712'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;ORDER&lt;/span&gt; &lt;span class="kw1"&gt;BY&lt;/span&gt;&lt;br /&gt; distance, zip_code&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;LIMIT&lt;/span&gt; &lt;span class="nu0"&gt;10&lt;/span&gt;, &lt;span class="nu0"&gt;1&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt; zipDistance&lt;br /&gt;&lt;span class="kw1"&gt;WHERE&lt;/span&gt;&lt;br /&gt;origin.zip_code = &lt;span class="st0"&gt;'27712'&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;AND&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;3956&lt;/span&gt; * ACOS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;br /&gt; SIN&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * SIN&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; +&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;origin.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; * COS&lt;span class="br0"&gt;(&lt;/span&gt;destination.lat * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; *&lt;br /&gt; COS&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;destination.lng - origin.lng&lt;span class="br0"&gt;)&lt;/span&gt; * &lt;span class="nu0"&gt;0.0174532925&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;)&lt;/span&gt;  &amp;lt;= zipDistance.distance&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;ORDER&lt;/span&gt; &lt;span class="kw1"&gt;BY&lt;/span&gt;&lt;br /&gt;distance, zip_code&lt;/pre&gt;&lt;br /&gt; &lt;table class="inline"&gt;&lt;br /&gt;  &lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;   &lt;th&gt;zip_code&lt;/th&gt;&lt;br /&gt;   &lt;th&gt;distance&lt;/th&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27712&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;0&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27704&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;4.75326963012033&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27705&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.34287681651191&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27708&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.57383981817397&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27503&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;5.58564401945863&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27701&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.41245709087189&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27706&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.58029004273494&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27709&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.59449266019943&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27702&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27710&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27711&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27715&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27717&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;   &lt;td&gt;27722&lt;/td&gt;&lt;br /&gt;   &lt;td&gt;6.61586916464669&lt;/td&gt;&lt;br /&gt;  &lt;/tr&gt;&lt;br /&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;Showing rows 0 - 13 (14 total, Query took 5.1353 sec)&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;So there you have it. In the second part of this series I will show how I use this same kind of logic to find the 10 closest locations from a database of addresses. Until then, enjoy!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-8376112183390915142?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/8376112183390915142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=8376112183390915142' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/8376112183390915142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/8376112183390915142'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2007/04/i-am-currently-involved-in-project.html' title='Zip Code Distances'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-4788021287972946587</id><published>2007-02-11T17:43:00.000-05:00</published><updated>2007-02-11T17:52:02.830-05:00</updated><title type='text'>On the Use of Captchas</title><content type='html'>In an earlier post, &lt;a href="http://blog.threeleaf.com/2006/12/29/php-form-signature/"&gt;PHP Form Signature&lt;/a&gt; I developed a bit of code to render form attacking bots harmless. On my own web sites I did expand the code to create a random hidden form field with the signature information, and on all the web sites I have implemented the signature methodology the obviously scripted form attacks were completely thwarted. At the same time, there is no usability impact since the mechanism works behind the scenes, completely hidden from the site visitor.&lt;br /&gt;&lt;br /&gt;However, as I predicted, one of my forms was spammed by a bot that simply harvested the form signature and reposted it along with its spam payload. Looking at the contents of the spam I immediately recognized that it was coded to work in a blog. This was not a targeted attack by someone who ran across a form on the site and developed a script to try to exploit it. Instead, this was a bot that was programmed to roam the web looking for any form that has a text area in it, and post there hoping that it will show up as a comment in someone's blog. This kind of attacker doesn't care whether any particular form submission works or fails, knowing only that there are enough unprotected blogs and similar public forums that will instantly display anonymous posts.&lt;br /&gt;&lt;br /&gt;This is exactly the kind of thing captchas were developed to prevent. However, as I have stated before, a captcha places a stumbling block in the way of innocent site visitors who truly do want to communicate. I have been on several sites that use a captcha on every form submission, which gets very annoying. The dilemma, then, is how one tells the difference between a robot and a human. After all, a robot can post HTTP header information to make it look like the POST is coming from an ordinary web browser.&lt;br /&gt;&lt;br /&gt;The main difference, that I can tell, is that nearly none of my human correspondents place links in their form submissions, but every one of the spam posts I have recorded contain one or more links. So, I have added to my form validation sequence a check for a link reference in posts. If it detects one, it re-presents the form with a captcha and prompts the visitor to fill in the letters they see in the image. A robot will never see that page, of course, but neither will their form POST be completely processed. The human visitor, who has likely seen captchas before, may still be annoyed with this interruption, but are much more likely to fill in the field as requested in order to complete their correspondence. In this way, I, as the web developer, protect my server and e-mail box, while providing a normal user experience to most of the visitors who use my forms.&lt;br /&gt;&lt;br /&gt;For the purposes of this example, I am using Ed Eliot's &lt;a href="http://www.ejeliot.com/pages/2"&gt;Visual and Audio PHP CAPTCHA Generation Class&lt;/a&gt;. The particular example I am giving also involves a form that posts to its same address ($_SERVER['SCRIPT_NAME']). This means that the model, or processing code, first checks to see if the request is a GET (automatically resulting in the form being presented) or a POST (which initiates the validation cycle).&lt;br /&gt;&lt;br /&gt;At the beginning of the model section of code, then, before any processing takes place, I have the following lines of code:&lt;br /&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;$useCaptcha = 1; // flag to indicate captcha can be displayed if needed&lt;br /&gt;$requireCaptcha = 0; // flag to indicate that a captcha condition has been met&lt;br /&gt;require_once('php-captcha.inc.php'); // Ed Elliot's captcha class&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Before I run the validation code, I fill in the $captchaTriggers array with any string that should cause a captcha to be displayed. The following will capture all links and images pasted in the form fields. You can add other rules, of course.&lt;br /&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;$captchaTriggers[] = 'http';&lt;br /&gt;$captchaTriggers[] = '&amp;lt;img';&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As part of my validation, I loop through the expected field names (I will likely cover details of my validation procedure in a later post, but this should give you the general idea). I check all the text fields for any of the captcha triggers. If one is found, then it's position is added to the $requireCaptcha variable.&lt;br /&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;if($_POST[$thisFieldName] &gt; ''){&lt;br /&gt;&amp;nbsp; &amp;nbsp; for ($j=0; $j&lt; sizeof($captchaTriggers); $j++) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $requireCaptcha += strpos(strtolower(' ' . $_POST[$thisFieldName]), strtolower($captchaTriggers[$j]));&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;...&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;At the end of the validation phase, I have the following code. If any of the captcha trigger strings was found in the above code, the value of $requireCaptcha will be greater than zero, which is one of the two conditions that need to be met ($useCaptcha being the second). If the conditions are met, the code then checks to see if the $_POST['captchaCode'] has been set, and if it validates against Elliot's captcha class. The first pass through, the captchaCode variable would not be present, of course, which then leads to the errorMessages array being set. On subsequent passes through, invalid captcha codes would continue to fail while a valid one will complete the processing (unless there are other validation errors, of course).&lt;br /&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;if($requireCaptcha &gt; 0 &amp;&amp; isset($useCaptcha)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(!isset($_POST['captchaCode'])) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $_POST['captchaCode'] = '';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; if (!PhpCaptcha::Validate($_POST['captchaCode'])) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $errorMessages[] = &amp;quot;Please enter the letters you see in the graphic.&amp;quot;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $errorFields[] = 'captchaCode';&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;All of my validation checks use the $errorMessages array, so my check on whether or not there were any validation errors is the determining factor on whether or not to display the form for corrections. In the form, I do another check for $requireCaptcha to determine whether or not to display the captcha image and field.&lt;br /&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;? if($requireCaptcha &amp;gt; 0) { ?&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;div class=&amp;quot;formRow&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;div class=&amp;quot;formLabel&amp;quot;&amp;gt;&amp;lt;label for=&amp;quot;captchaCode&amp;quot;&amp;gt;&amp;lt;img src=&amp;quot;/assets/images/visual-captcha.php&amp;quot; width=&amp;quot;100&amp;quot; height=&amp;quot;40&amp;quot; alt=&amp;quot;Visual CAPTCHA&amp;quot; /&amp;gt;&amp;lt;/label&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;div class=&amp;quot;formField&amp;quot;&amp;gt;&amp;lt;input type=&amp;quot;text&amp;quot; id=&amp;quot;captchaCode&amp;quot; name=&amp;quot;captchaCode&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;width:10em;&amp;quot; maxlength=&amp;quot;10&amp;quot; accesskey=&amp;quot;c&amp;quot; tabindex=&amp;quot;5&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;? } ?&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Since I have implemented this code, I have not received any robot generated spam. One possible improvement is to set a cookie in the client browser when a captcha challenge is successfully answered. The cookie would essentially say "this user has already proven that they are human, so you do not need to challenge them in the future."&lt;br /&gt;&lt;br /&gt;Hope this helps you!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-4788021287972946587?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/4788021287972946587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=4788021287972946587' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/4788021287972946587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/4788021287972946587'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2007/02/on-use-of-captchas.html' title='On the Use of Captchas'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-117026882287597747</id><published>2007-01-31T13:39:00.000-05:00</published><updated>2007-01-31T13:40:44.646-05:00</updated><title type='text'>Dynamic Copyright Dates</title><content type='html'>Copyright notices remind web site visitors that the content of a web page belongs to the web site owners and cannot be legally reproduced without permission (with some exceptions - search for other resources for more information). To fully protect the content of a site, most web site owners place the copyright notice in the footer of each page. It is normal to update the copyright year with the current year.&lt;br /&gt;&lt;br /&gt;When most web sites are launched, they have only a few pages, and if they use includes, normally only have one footer file.  It is quite easy to simply hard code the current year in the footer. However, as web sites grow larger, the maintenance can become more difficult if the copyright has been hard coded in every page or if more than one footer becomes necessary (for example if a web site uses multiple designs for different sections of the site or if different sections are written in different languages).&lt;br /&gt;&lt;br /&gt;Rather than hard coding the year, it may be more efficient to dynamically generate the year in each footer. Below I have example snippets showing how this can be done in a few different languages. Feel free to add your own suggestions.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;PHP&lt;/h2&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;amp;copy; &amp;lt;? print date("Y"); ?&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2&gt;ColdFusion&lt;/h2&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;amp;copy; &amp;lt;cfoutput&amp;gt;#dateFormat(Now(), &amp;quot;yyyy&amp;quot;)#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2&gt;JSP&lt;/h2&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;%@ page language=&amp;quot;java&amp;quot; contentType=&amp;quot;text/html&amp;quot; session=&amp;quot;true&amp;quot; %&amp;gt;&lt;br /&gt;&amp;lt;%@ taglib prefix=&amp;quot;fmt&amp;quot; uri=&amp;quot;http://java.sun.com/jsp/jstl/fmt&amp;quot; %&amp;gt;&lt;br /&gt;&amp;lt;jsp:useBean id=&amp;quot;now&amp;quot; class=&amp;quot;java.util.Date&amp;quot; /&amp;gt;&lt;br /&gt;...&lt;br /&gt;&amp;amp;copy; &amp;lt;fmt:formatDate value=&amp;quot;${now}&amp;quot; pattern=&amp;quot;yyyy&amp;quot; /&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2&gt;JavaScript&lt;/h2&gt;&lt;br /&gt;The following code can be used in static HTML pages or in place of any of the above. It requires no server side work, but it does mean that the browsing client must have JavaScript enabled.&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;amp;copy; &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;d=new Date();document.write(d.getFullYear());&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-117026882287597747?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/117026882287597747/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=117026882287597747' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/117026882287597747'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/117026882287597747'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2007/01/dynamic-copyright-dates.html' title='Dynamic Copyright Dates'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-116743873409202640</id><published>2006-12-29T19:31:00.000-05:00</published><updated>2006-12-29T19:32:14.400-05:00</updated><title type='text'>PHP Form Signature</title><content type='html'>In my previous post, I began developing the concept of creating a checksum for a form to help prevent spammers from abusing forms on web sites. A malicious spammer will first attempt to inject code into a form in an effort to send e-mails through the web site's host. Those attempts can usually be foiled by properly validating the form fields. However, a spammer may still inject their marketing materials into a form that appears to send an e-mail to someone, not really caring where that e-mail might wind up. If these e-mails are directed at a server administrator or the customer support staff, they can get very annoying, even if they are otherwise rendered harmless by the validation rules. The goal then is to try to ensure that a given form post if from a human being, and not from a robot. Visual and verbal "captchas" can be used, but that tends to annoy the human visitor, which we don't want to do.&lt;br /&gt;&lt;br /&gt;The idea of using a checksum and a form timeout is one way a web developer might attempt to prevent a spammer from writing bots against forms. I am expanding on the idea of the checksum and will now call it a signature. This example is in PHP, and will work as-is, but I certainly encourage you to make your own variations.&lt;br /&gt;&lt;br /&gt;In my previous post, I developed an example with two hidden fields which were used to validate the form post. In this example I do two things: 1) combine the timestamp and the hash to create one "signature" field, and 2) encrypt the timestamp to make it less obvious. These measures should make it more difficult for a robot to spoof posts to your forms. Note that with any encryption and hash scheme, it is possible to break the code, but the objective here is to make it so arduous that the spammer would rather look elsewhere for targets than your forms. My opinion is that it would probably be easier for someone to hack the server than this form validation technique, so one must not overlook hardening the rest of the server, of course.&lt;br /&gt;&lt;br /&gt;Since you might use this code in several places, consider making it an include:&lt;br /&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;?&lt;br /&gt;// http://rc4crypt.devhome.org/&lt;br /&gt;include_once 'cryptography.php';&lt;br /&gt;&lt;br /&gt;function formSignatureCreate($formPassword){&lt;br /&gt;&amp;nbsp; &amp;nbsp; $formTime = array_sum(explode(' ', microtime()));&lt;br /&gt;&amp;nbsp; &amp;nbsp; $encryptedTime = encrypt($formTime, $formPassword);&lt;br /&gt;&amp;nbsp; &amp;nbsp; $hash = formSignatureHash($formTime, $formPassword . $encryptedTime);&lt;br /&gt;&amp;nbsp; &amp;nbsp; return $hash . $encryptedTime;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function formSignatureValidate($formSignature, $formPassword){&lt;br /&gt;&amp;nbsp; &amp;nbsp; $encryptedTime = substr($formSignature, 32);&lt;br /&gt;&amp;nbsp; &amp;nbsp; $formTime = decrypt($encryptedTime, $formPassword);&lt;br /&gt;&amp;nbsp; &amp;nbsp; $hash = formSignatureHash($formTime, $formPassword . $encryptedTime);&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(!is_numeric($formTime)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; $currentTime = array_sum(explode(' ', microtime()));&lt;br /&gt;&amp;nbsp; &amp;nbsp; if($currentTime - $formTime &amp;gt; 1800) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; if($_SERVER['HTTP_USER_AGENT'] == ''){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; if($hash == substr($formSignature, 0, 32)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return true;&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; return false;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function formSignatureHash($formTime, $formPassword){&lt;br /&gt;&amp;nbsp; &amp;nbsp; return md5($formTime . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . $_SERVER['SERVER_NAME'] . $formPassword);&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The &lt;strong&gt;encrypt&lt;/strong&gt; and &lt;strong&gt;decrypt&lt;/strong&gt; functions are wrappers I have placed around the rc4crypt code. You may use any encryption technique you want, of course, as I am only showing this as an example. These functions include a conversion of the encrypted string to base 64, so I do not have to deal with making the string web-friendly at this level.&lt;br /&gt;&lt;br /&gt;For the time stamp (&lt;strong&gt;$formTime&lt;/strong&gt;) , I have used the &lt;strong&gt;microtime()&lt;/strong&gt; PHP function for simplicity, but you could use a formatted time as well, along with appropriate changes in the &lt;strong&gt;formSignatureValidate()&lt;/strong&gt; function. This time stamp is encrypted with a password designated by the programmer. It is probably a best practice to have a unique password with each form, and since it is on the programming side, it can be a random sequence of characters.&lt;br /&gt;&lt;br /&gt;The hash is generated in the &lt;strong&gt;formSignatureHash()&lt;/strong&gt; function, which combines the following elements:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;strong&gt;$formTime&lt;/strong&gt; - The time the form was created, which allows us to validate that the form POST was submitted within a certain time frame.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;strong&gt;REMOTE_ADDR&lt;/strong&gt; - To tie the form post with the client's computer.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;strong&gt;HTTP_USER_AGENT&lt;/strong&gt; - To tie the form post with the client's browser.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;strong&gt;SERVER_NAME&lt;/strong&gt; - To tie the form to a given host server.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;strong&gt;$formPassword&lt;/strong&gt; - To tie the form POST to a given form.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Just to further confound any reverse-engineering, I combine the encrypted time with the given form password when the hash function is called.&lt;br /&gt;&lt;br /&gt;Within the form, add a hidden field for the signature:&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;? $signature = formSignatureCreate('thisFormPassword'); ?&amp;gt;&lt;br /&gt;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;signature&amp;quot; value=&amp;quot;&amp;lt;? print $signature; ?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The way I have set this example up, a new signature would be created if other validation checks failed. This eliminates the need to validate the basic form (i.e., alpha-numeric) of the signature itself before printing it back into the form. We would not want someone attempting to inject code into an unvalidated signature variable!&lt;br /&gt;&lt;br /&gt;In your validation section, add the signature check:&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;if(formSignatureValidate($signature, 'thisFormPassword')) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; // other form validation&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; // spawn error message&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;During validation, I make this my primary check. If the post does not pass the signature check, there is no reason to do any other validation, since it will always be rejected. In my error messaging system, I do not even display the input form again, forcing the visitor to click on a link to start the original form over. You may wish to restart a little more graciously with a blank form.&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;formSignatureValidate()&lt;/strong&gt; function first decrypts the time portion of the signature. In this example, the hash portion is always 32 characters long, so it is easy to pull the encrypted time off the end. Since I have used the &lt;strong&gt;microtime()&lt;/strong&gt; function, it is easy to check to be sure the timestamp is 1) numeric and 2) within the 30 minute (1,800 second) time frame allowed.&lt;br /&gt;&lt;br /&gt;I do an additional check on &lt;strong&gt;HTTP_USER_AGENT&lt;/strong&gt; only because one of my sites was once attacked by a robot without a name. I don't bother checking during the signature creation phase, since it is really only important in the validation phase. If you know of specific rogue agents or IP addresses, those can be globally addressed in an .htaccess file or in the server configuration.&lt;br /&gt;&lt;br /&gt;The final check is that the regenerated hash matches the hash at the beginning of the signature.&lt;br /&gt;&lt;br /&gt;If all these checks pass, then it is considered a genuine post.&lt;br /&gt;&lt;br /&gt;I have thought of a way to defeat this methodology. Someone could certainly develop a script to "screen scrape" the signature dynamically, but hopefully, a spammer will consider that too much effort. If the need arises, it is likely one could come up with a methodology to dynamically create the signature name as well. Time will tell. In the meantime, I hope this helps someone. I hope to develop a Java/JSP version of this in the near future.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-116743873409202640?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/116743873409202640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=116743873409202640' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/116743873409202640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/116743873409202640'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/12/php-form-signature.html' title='PHP Form Signature'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-116492546519657401</id><published>2006-11-30T17:23:00.000-05:00</published><updated>2006-11-30T17:25:58.216-05:00</updated><title type='text'>Thwarting form spammers in ColdFusion</title><content type='html'>&lt;p&gt;As I have posted on before, spammers are more and more attempting to use form posting methods to send emails through unsuspecting web hosts. The most dangerous form, of course, are posts through which the spammer injects code that is run invisibly on the server. This approach can often be foiled by verifying form post data and properly escaping characters before they are displayed anywhere.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;I have added validation to all the forms on the web site for the main company I work for, but one spammer is still attempting to use a form. However, the only destination is an administrative e-mail box, so the spammer has expended a lot of effort to effectively annoy only a few people. We have been receiving about 100 spam messages a day in the box, so further action was needed to stop this spammer and any other who might follow after.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;One common solution has been the "captcha," a graphic with hard-to-read text that only the human brain can theoretically interpret and relay back to the server to prove the post did not originate from a robot. For our purposes, however, this approach is undesirable since it makes forms less usable. I wanted to come up with a verification process that is invisible to humans and would be (nearly?) impossible for a robot to reproduce.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;My solution is to create a checksum value that would consist of data from the server, from the client, and from the form that could be matched up before and after the post to "prove" it to be authentic. Taking a page from our login guidelines, I thought it also appropriate to have forms time stamped, further hindering the likelihood that the checksum could be duplicated, and would certainly make it impossible for a "good" post to be reused at a later time.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;This first solution is in ColdFusion since that is what this company uses the most right now. I plan to follow shortly with a PHP example followed by a Java/JSP example.&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Creating the Checksum&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;The following code creates the checksum value. Any number of variables can be used to create the checksum, with the only requirement being that the values at the time of validation have to be the same as the time of posting.&lt;/P&gt;&lt;br /&gt;&lt;p&gt;This code uses the following four values:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;strong&gt;dateTime&lt;/strong&gt; - The time the form was created, which allows us to validate that the form POST was submitted within a certain time frame.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;strong&gt;remoteAddress&lt;/strong&gt; - The client machine's address, which allows us to validate that the form POST arrived from the same machine that requested the original form. Specifically, this would thwart spammers who use Trojans to hijack unprotected computers and make them spam zombies.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;strong&gt;serverName&lt;/strong&gt; - This is the web server's domain name in this example. If your servers are inside a firewall, and/or if you have multiple, load balanced servers with "sticky persistence" (i.e., a client is guaranteed to always communicate with one particular server during its session), you might use either the server's IP address or a global variable specific to a given server.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;strong&gt;formName&lt;/strong&gt; - On sites that I program, each form is given a unique name. Originally, this was for statistical usage purposes, but it can also come in handy here. This is essentially a "password" for the form data, preventing a given set of validation code from attempting to validate data from a different form.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;Overall, this system attempt to guarantee that communication about one form is transferred between a known host and a known client within a known time span. Any detected violation prevents validation from proceeding. Hashing this data using a technique like MD5 creates a checksum that should be virtually impossible to reverse-engineer. Even though spammers are persistent, they are more likely to hack someone else's less protected site than tackle this problem.&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;cfparam name=&amp;quot;form.dateTime&amp;quot; default=&amp;quot;#DateFormat(Now(),'yyyy-mm-dd')# #TimeFormat(Now(),'HH:mm:ss')#&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;cfset remoteAddress = cgi.REMOTE_ADDR&amp;gt;&lt;br /&gt;&amp;lt;cfset serverName = cgi.SERVER_NAME&amp;gt;&lt;br /&gt;&amp;lt;cfset formName = &amp;quot;formSomeName&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;cfset form.checksum = hash(&amp;quot;#form.dateTime#~#formName#~#remoteAddress#~#serverName#&amp;quot;)&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The next piece of code is added into the form. The only two pieces of information in clear text are the dateTime and checksum values (now that I think about it, these two values could actually be encrypted and given different names to further enhance security - I will most likely do that in further form work). All of the other variables live on the server, and the spammer would have to know all this, including your separators and the exact sequence of variables used, in order to forge the checksum value (not likely without inside help or an outright takeover of your server).&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;dateTime&amp;quot; value=&amp;quot;#form.dateTime#&amp;quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;checksum&amp;quot; value=&amp;quot;#form.checksum#&amp;quot; /&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;On the validation side, you want to add the following code at the top.&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;cfif cgi.REQUEST_METHOD IS NOT &amp;quot;POST&amp;quot; OR NOT isDefined(&amp;quot;form.checksum&amp;quot;)&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;cflocation url=&amp;quot;/&amp;quot; addtoken=&amp;quot;No&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;/cfif&amp;gt;&lt;br /&gt;&amp;lt;cfset remoteAddress = cgi.REMOTE_ADDR&amp;gt;&lt;br /&gt;&amp;lt;cfset serverName = cgi.SERVER_NAME&amp;gt;&lt;br /&gt;&amp;lt;cfset formName = &amp;quot;formSomeName&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;cfset checksumTest = hash(&amp;quot;#form.dateTime#~#formName#~#remoteAddress#~#serverName#&amp;quot;)&amp;gt; &lt;br /&gt;&amp;lt;cfif checksumTest IS NOT form.checksum&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;cfset errorMessage = &amp;quot;The form data was corrupted. We are sorry, but we cannot send your request at this time.&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;/cfif&amp;gt;&lt;br /&gt;&amp;lt;cfif isDate(form.dateTime)&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;cfif checksumTest IS form.checksum AND DateDiff(&amp;quot;n&amp;quot;, form.dateTime, now()) GT 30&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;cfset errorMessage = &amp;quot;The form data has expired. We are sorry, but we cannot send your request at this time.&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/cfif&amp;gt;&lt;br /&gt;&amp;lt;cfelse&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;cfset errorMessage = &amp;quot;The form date was corrupted. We are sorry, but we cannot send your request at this time.&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;/cfif&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;If the errorMessages is set, you most likely want to halt further validation to prevent any harmful code from affecting anything you have missed validating. At this point you are already aware that something is amiss! This should not be your only line of defense, however. You still want to validate every field to make sure it contains data of the right datatype, length, and is free from characters that could lead to other hacks.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-116492546519657401?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/116492546519657401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=116492546519657401' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/116492546519657401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/116492546519657401'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/11/thwarting-form-spammers-in-coldfusion.html' title='Thwarting form spammers in ColdFusion'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-116491072655824214</id><published>2006-11-30T13:17:00.000-05:00</published><updated>2006-11-30T13:51:45.280-05:00</updated><title type='text'>CSS hack to differentiate between IE 6 and 7</title><content type='html'>&lt;p&gt;I discovered this quite by accident, and thought this might be helpful for those who find they need to set up different stylesheet rules for formatting in Internet Explorer 6 and IE 7. The crux of this solution is the CSS attribute selector (dentoned as square brackets [] in CSS). It turns out that IE6 does not understand attribute selectors, and, in fact, will ignore the entire associated rule (including rules with more than one selector).&lt;/p&gt;&lt;br /&gt;&lt;p&gt;To leverage this difference, two rules can be defined. A normal rule that will be rendered in IE6, and a duplicate rule containing an attribute selector that will be rendered in IE7. In the example below, I use the IE-specific "if" statement to show how you can further differentiate between IE and "other browsers." The solution below was tested in the Windows environment using IE6, IE7, Oprah 9, and Firefox 2.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;If you use a different browser or environment, try the code out and let me know what you see.&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Transitional//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;html lang=&amp;quot;en&amp;quot; xml:lang=&amp;quot;en&amp;quot; xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;title&amp;gt;CSS hack to differentiate between IE 6 and 7&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;meta name=&amp;quot;author&amp;quot; content=&amp;quot;John A. Marsh&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;meta name=&amp;quot;copyright&amp;quot; content=&amp;quot;&amp;amp;copy; 2006 ThreeLeaf.com&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; P {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; background:green;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/style&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;!--[if IE]&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; P {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; background:red;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; P[],P {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; background:blue;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/style&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;![endif]--&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;p&amp;gt;Blue in IE 6, Red in IE 7, Green in non-IE browsers.&amp;lt;/p&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-116491072655824214?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/116491072655824214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=116491072655824214' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/116491072655824214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/116491072655824214'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/11/css-hack-to-differentiate-between-ie-6.html' title='CSS hack to differentiate between IE 6 and 7'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-116224160541583024</id><published>2006-10-30T15:52:00.000-05:00</published><updated>2006-11-30T13:24:18.316-05:00</updated><title type='text'>JavaScript parent / child communication example</title><content type='html'>&lt;p&gt;In a test I was running, I needed a valid date of birth in mm/dd/yyyy format. Here is the solution I came up with:&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace"&gt;${__javaScript(with(new Date()) dob = String(Math.floor(Math.random() * 12) + 101).substr(1) + '/' + String(Math.floor(Math.random() * 28) + 101).substr(1) + '/' + String(getFullYear() - Math.floor(Math.random() * 99) - 1), dateString)}&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The plain JavaScript version is&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace"&gt;with(new Date()) dob = String(Math.floor(Math.random() * 12) + 101).substr(1) + '/' + String(Math.floor(Math.random() * 28) + 101).substr(1) + '/' + String(getFullYear() - Math.floor(Math.random() * 99) -1 ); alert(dob);&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The first part gives us a zero padded month from 01-12. The second part gives a zero padded day from 01-28 (I did not want to deal with leap years and end-of month guessing for this test). The final part subtracts 1 to 100 from the current year (guaranteeing no future dates in the current year). Quick and dirty -- Enjoy!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-116224160541583024?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/116224160541583024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=116224160541583024' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/116224160541583024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/116224160541583024'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/10/javascript-parent-child-communication.html' title='JavaScript parent / child communication example'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-114677594420110682</id><published>2006-05-04T15:41:00.000-05:00</published><updated>2006-11-30T13:46:11.136-05:00</updated><title type='text'>Struts Upgrade - Validation-rules.xml - Solution</title><content type='html'>&lt;p&gt;At the company where I work, we are upgrading our WebSphere servers from version 5 to 6. In the process, we are also updating our Java applications. Part of the application upgrades involve converting from Struts 1.1 to 1.2.8.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;I have spent two days puzzled by the problem this caused with form bean validation. I was getting errors like this:&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;[5/3/06 9:46:11:643 EDT] 00000057 DynaValidator E org.apache.struts.validator.DynaValidatorForm validate org.apache.struts.validator.FieldChecks.validateMask(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest)&lt;br /&gt;org.apache.commons.validator.ValidatorException: org.apache.struts.validator.FieldChecks.validateMask(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest)&lt;br /&gt;at org.apache.commons.validator.ValidatorAction.loadValidationMethod(ValidatorAction.java:627)&lt;br /&gt;at org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:557)&lt;br /&gt;at org.apache.commons.validator.Field.validateForRule(Field.java:827)&lt;br /&gt;at org.apache.commons.validator.Field.validate(Field.java:906)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The error message gives no indication of what the actual problem is, and while I found several posts on the Internet of people who have had the problem, I have not seen any solutions yet. My best clue was from an article in the &lt;a href="http://wiki.apache.org/struts/StrutsUpgradeNotes124to127" target="_blank"&gt;Apache Wiki&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The root cause is that the validation method's signature has changed. Another issue is that the old ActionError method has been depricated and replaced with ActionMessages. Rules in your validation-rules.xml file should now look like this:&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&amp;lt;validator name="required"&lt;br /&gt;classname="org.apache.struts.validator.FieldChecks"&lt;br /&gt;method="validateRequired"&lt;br /&gt;methodParams="java.lang.Object,&lt;br /&gt;org.apache.commons.validator.ValidatorAction,&lt;br /&gt;org.apache.commons.validator.Field,&lt;br /&gt;&lt;strong&gt;org.apache.struts.action.ActionMessages&lt;/strong&gt;,&lt;br /&gt;&lt;strong&gt;org.apache.commons.validator.Validator&lt;/strong&gt;,&lt;br /&gt;javax.servlet.http.HttpServletRequest"&lt;br /&gt;msg="errors.required"/&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Hope that helps someone&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-114677594420110682?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/114677594420110682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=114677594420110682' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/114677594420110682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/114677594420110682'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/05/struts-upgrade-validation-rulesxml.html' title='Struts Upgrade - Validation-rules.xml - Solution'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-114592580579888435</id><published>2006-04-24T19:42:00.000-05:00</published><updated>2006-11-30T13:26:25.000-05:00</updated><title type='text'>Exporting Outlook Contacts Folders - Solution</title><content type='html'>&lt;P&gt;A problem I have run across a couple of times, and have noticed that many others have is exporting Microsoft Outlook Contacts folders to a comma separated values (CSV) file. By default Outlook can only export one folder at a time. I have not found any software add-on yet that can do this either.&lt;/P&gt;&lt;br /&gt;&lt;P&gt;However, I have discovered by accident a way to do this using the &lt;A href="http://www.plaxo.com/" target=_blank&gt;Plaxo&lt;/A&gt;&amp;nbsp;service. Plaxo comes as an optional install with the &lt;A href="http://www.aim.com/" target=_self&gt;AOL Instant Messenger Triton&lt;/A&gt; application. I personally could not use Triton because it lacks Proxy settings or any way to change the communication port.&lt;/P&gt;&lt;br /&gt;&lt;P&gt;Anyway, when you use Plaxo, you can upload all your contacts to their web sites, and a fortunate side effect (depending on how seriously you take your privacy), it can help you discover your contacts' AIM addresses, and if they also are in Plaxo, will share whatever information the person allows to share.&lt;/P&gt;&lt;br /&gt;&lt;P&gt;One feature is that you can export your contact list. You are given the option to export all your contacts or any one folder of your choice. The download options are:&lt;/P&gt;&lt;br /&gt;&lt;UL&gt;&lt;br /&gt;&lt;LI&gt;Microsoft Outlook (.CSV file)&lt;br /&gt;&lt;LI&gt;Outlook Express (.CSV file)&lt;br /&gt;&lt;LI&gt;Palm (.CSV file)&lt;br /&gt;&lt;LI&gt;Netscape (.LDIF file)&lt;br /&gt;&lt;LI&gt;Yahoo! (.CSV file)&lt;br /&gt;&lt;LI&gt;vCard (.VCF file)&lt;/LI&gt;&lt;/UL&gt;&lt;br /&gt;&lt;P&gt;Hope this helps someone! Let me know if you have comments or questions. My main question is why can't Microsoft make this easier???&lt;/P&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-114592580579888435?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/114592580579888435/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=114592580579888435' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/114592580579888435'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/114592580579888435'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/04/exporting-outlook-contacts-folders.html' title='Exporting Outlook Contacts Folders - Solution'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-114185856906054374</id><published>2006-03-08T17:53:00.000-05:00</published><updated>2006-11-30T13:28:49.713-05:00</updated><title type='text'>VBScript / Excel / SendKeys / Sleep - Solution</title><content type='html'>&lt;p&gt;This is a script I wrote to help me add IPTC information to over 1200 images. It contains several techniques you might be able to use in your own VBScripts.&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;' Based on a script to automate Excel with VBscript by Richard L. Mueller&lt;br /&gt;' Demonstrates several additional functions including&lt;br /&gt;' 1) Launching applications&lt;br /&gt;' 2) using SendKeys to control application&lt;br /&gt;' 3) useing Sleep to pause execution during the script&lt;br /&gt;' 4) Arrays&lt;br /&gt;&lt;br /&gt;' I wrote this script to help me update the IPTC data of images&lt;br /&gt;' I had downloaded the data from MySQL and put it in an Excel spreadsheet&lt;br /&gt;' Each line of the spreadsheet contains the file name and the desired IPTC information&lt;br /&gt;' I leverage IrfanView to insert the IPTC information into each photograph&lt;br /&gt;' This IPTC information is later read by the server using PHP when I upload the pictures to my photography web site&lt;br /&gt;&lt;br /&gt;' You have a royalty-free right to use, modify, reproduce, and&lt;br /&gt;' distribute this script file in any way you find useful, provided that&lt;br /&gt;' you agree that the copyright owner above has no warranty, obligations,&lt;br /&gt;' or liability for such use.&lt;br /&gt;&lt;br /&gt;Option Explicit&lt;br /&gt;&lt;br /&gt;Dim objExcel, strExcelPath, objSheet, intRow&lt;br /&gt;dim fileName, pictureTitle, pictureDescription, keywords, categoryID, thisYear, originalDate, filesys&lt;br /&gt;&lt;br /&gt;' Bind to Excel object.&lt;br /&gt;On Error Resume Next&lt;br /&gt;Set objExcel = CreateObject(&amp;quot;Excel.Application&amp;quot;)&lt;br /&gt;If Err.Number &amp;lt;&amp;gt; 0 Then&lt;br /&gt;  On Error GoTo 0&lt;br /&gt;  WScript.Echo &amp;quot;Excel application not found.&amp;quot;&lt;br /&gt;  WScript.Quit&lt;br /&gt;End If&lt;br /&gt;On Error GoTo 0&lt;br /&gt;&lt;br /&gt;strExcelPath = &amp;quot;C:\Temp\originals\tblPictures.xls&amp;quot;&lt;br /&gt;&lt;br /&gt;' Open specified spreadsheet and select the first worksheet.&lt;br /&gt;objExcel.WorkBooks.Open strExcelPath&lt;br /&gt;Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)&lt;br /&gt;&lt;br /&gt;dim category(9)&lt;br /&gt;category(1) = &amp;quot;Plants&amp;quot;&lt;br /&gt;category(2) = &amp;quot;Animals&amp;quot;&lt;br /&gt;category(3) = &amp;quot;Landscapes&amp;quot;&lt;br /&gt;category(4) = &amp;quot;Textures&amp;quot;&lt;br /&gt;category(5) = &amp;quot;Structures&amp;quot;&lt;br /&gt;category(6) = &amp;quot;Miscellaneous&amp;quot;&lt;br /&gt;category(7) = &amp;quot;John&amp;quot;&lt;br /&gt;category(8) = &amp;quot;People&amp;quot;&lt;br /&gt;category(9) = &amp;quot;Transportation&amp;quot;&lt;br /&gt;&lt;br /&gt;dim WshShell&lt;br /&gt;Set WshShell = WScript.CreateObject(&amp;quot;WScript.Shell&amp;quot;)&lt;br /&gt;Set filesys = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;) &lt;br /&gt;&lt;br /&gt;'Get copyright symbol - VBScript does not have a way to do an alt-0169 combination&lt;br /&gt;&lt;br /&gt;Dim charMap&lt;br /&gt;charMap = WshShell.Run(&amp;quot;CharMap&amp;quot;)&lt;br /&gt;WScript.Sleep 250&lt;br /&gt;WshShell.AppActivate charMap&lt;br /&gt;WScript.Sleep 250&lt;br /&gt;WshShell.SendKeys &amp;quot;{TAB}{TAB}{RIGHT 3}{DOWN 5}~&amp;quot;&lt;br /&gt;WScript.Sleep 250&lt;br /&gt;WshShell.SendKeys &amp;quot;%F&amp;quot;&lt;br /&gt;WScript.Sleep 250&lt;br /&gt;WshShell.SendKeys &amp;quot;Times New Roman&amp;quot;&lt;br /&gt;WScript.Sleep 250&lt;br /&gt;WshShell.SendKeys &amp;quot;%C&amp;quot;&lt;br /&gt;WScript.Sleep 250&lt;br /&gt;WshShell.SendKeys &amp;quot;%{F4}&amp;quot;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;' Iterate through the rows of the spreadsheet after the first, until the&lt;br /&gt;' first blank entry in the first column. For each row, bind to the user&lt;br /&gt;' specified in the first column and set attributes.&lt;br /&gt;intRow = 2&lt;br /&gt;Do While objSheet.Cells(intRow, 1).Value &amp;lt;&amp;gt; &amp;quot;&amp;quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; originalDate = Mid(objSheet.Cells(intRow, 1).Value, 4, 8)&lt;br /&gt;&amp;nbsp; &amp;nbsp; fileName = &amp;quot;C:\Temp\originals\&amp;quot; &amp;amp; objSheet.Cells(intRow, 1).Value&lt;br /&gt;&amp;nbsp; &amp;nbsp; if filesys.FileExists(fileName) Then &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pictureTitle = objSheet.Cells(intRow, 2).Value&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; categoryID = objSheet.Cells(intRow, 3).Value&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pictureDescription = objSheet.Cells(intRow, 4).Value&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; keywords = objSheet.Cells(intRow, 5).Value&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ' On Error Resume Next&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; thisYear = mid(originalDate, 1, 4)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.Run (&amp;quot;C:\Programs\Graphics\I-View\i_view32.exe &amp;quot; &amp;amp; fileName)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.AppActivate &amp;quot;IrfanView&amp;quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;i&amp;quot;, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;%i&amp;quot;, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;^v &amp;quot; &amp;amp; thisYear &amp;amp; &amp;quot; John A. Marsh, all rights reserved&amp;quot; &amp;amp; &amp;quot;{TAB}&amp;quot;, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys replace(replace(pictureDescription, &amp;quot;(&amp;quot;, &amp;quot;{(}&amp;quot;), &amp;quot;)&amp;quot;, &amp;quot;{)}&amp;quot;) &amp;amp; &amp;quot;{TAB}John A. Marsh{TAB}&amp;quot;, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys pictureTitle &amp;amp; &amp;quot;{TAB}&amp;quot;, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'WshShell.SendKeys frmOptions.infoInstructions.Text, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;^{TAB}&amp;quot; &amp;amp; keywords, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;^{TAB}&amp;quot; &amp;amp; category(categoryID), True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;^{TAB}John A. Marsh{TAB}Photographer / Owner{TAB}John A. Marsh{TAB}http://www.johnmarshphotography.com/&amp;quot;, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;^{TAB}&amp;quot; &amp;amp; pictureTitle, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;{TAB}&amp;quot;, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys thisYear &amp;amp; &amp;quot;{TAB}&amp;quot; &amp;amp; Mid(originalDate, 5, 2) &amp;amp; &amp;quot;{TAB}&amp;quot; &amp;amp; Mid(originalDate, 7, 2) &amp;amp; &amp;quot;{TAB}{TAB}&amp;quot;, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;Durham{TAB}North Carolina, NC{TAB}United States of America, USA{TAB}&amp;quot;, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;{ENTER}&amp;quot;, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;%o&amp;quot;, True&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WshShell.SendKeys &amp;quot;%{F4}&amp;quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WScript.Sleep 250&lt;br /&gt;&amp;nbsp; &amp;nbsp; end if&lt;br /&gt;&amp;nbsp; &amp;nbsp; intRow = intRow + 1&lt;br /&gt;Loop&lt;br /&gt;&lt;br /&gt;' Close workbook and quit Excel.&lt;br /&gt;objExcel.ActiveWorkbook.Close&lt;br /&gt;objExcel.Application.Quit&lt;br /&gt;&lt;br /&gt;' Clean up.&lt;br /&gt;Set objExcel = Nothing&lt;br /&gt;Set objSheet = Nothing&lt;br /&gt;&lt;br /&gt;WScript.Echo &amp;quot;Done&amp;quot;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sub IrfanviewIPTC(fileName)&lt;br /&gt;&lt;br /&gt;'Add IPTC data to image via SendKeys commands to IrfanView&lt;br /&gt;&lt;br /&gt;'start application&lt;br /&gt;'Dim appIrfanView&lt;br /&gt;'appIrfanView = Shell(&amp;quot;C:\Programs\Graphics\I-View\i_view32.exe &amp;quot; &amp;amp; fileName)&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-114185856906054374?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/114185856906054374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=114185856906054374' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/114185856906054374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/114185856906054374'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/03/vbscript-excel-sendkeys-sleep-solution.html' title='VBScript / Excel / SendKeys / Sleep - Solution'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-114055467653291243</id><published>2006-02-21T15:36:00.000-05:00</published><updated>2006-11-30T13:30:13.806-05:00</updated><title type='text'>JMeter Birthday Boundary Testing - Solution</title><content type='html'>&lt;p&gt;One of the applications I was testing today required a boundary test for people aged 65 years old. To do this, I set up two variables, one with a generated date exactly 65 years ago, and the other being 65 years old plus one day, thus giving an age of 64.&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;age64:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;${__javaScript(with(new Date()) X = String(getMonth() + 101).substr(1) + "/" + String(getDate() + 101).substr(1) + "/" + String(getFullYear() - 65), dateString)}&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;age65:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;${__javaScript(with(new Date()) X = String(getMonth() + 101).substr(1) + "/" + String(getDate() + 100).substr(1) + "/" + String(getFullYear() - 65), dateString)}&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Note that this will fail on the last day of the month and the day before a leap day. But hey, you have been working hard all month ... take a day or two off! ;-)&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-114055467653291243?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/114055467653291243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=114055467653291243' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/114055467653291243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/114055467653291243'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/02/jmeter-birthday-boundary-testing.html' title='JMeter Birthday Boundary Testing - Solution'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-114001817082833483</id><published>2006-02-15T10:41:00.000-05:00</published><updated>2006-11-30T13:31:49.820-05:00</updated><title type='text'>Formatted Date in JMeter / JavaScript - Solution 2</title><content type='html'>&lt;p&gt;In another JMeter testing scenario, I wanted to set a user defined variable to a date string with the format &amp;quot;yyyymmddhhmmss&amp;quot;. The solution below solved the problem of left-padding with zeros and getting all the formatting done in a single line.&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;${__javaScript(with(new Date()) X = getFullYear() + String(getMonth() + 101).substr(1) + String(getDate() + 100).substr(1) + String(getHours() + 100).substr(1) + String(getMinutes() + 100).substr(1) + String(getSeconds() + 100).substr(1), dateString)}&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The uses of this kind of user variable include:&lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt; &lt;li&gt;Knowing exactly when a test was run for auditing&lt;/li&gt;&lt;br /&gt; &lt;li&gt;Guaranteeing a unique string for things like new test usernames [note that I am writing regression tests which only run once. If you are running load tests, you will want to add String(getMilliseconds() + 1000).substr(1) to get unique string each pass]&lt;/li&gt;&lt;br /&gt; &lt;li&gt;Having a string you can key off of, for example to clean up database entries you have made&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-114001817082833483?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/114001817082833483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=114001817082833483' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/114001817082833483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/114001817082833483'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/02/formatted-date-in-jmeter-javascript_15.html' title='Formatted Date in JMeter / JavaScript - Solution 2'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-113915079371292946</id><published>2006-02-05T09:46:00.000-05:00</published><updated>2006-11-30T13:34:47.676-05:00</updated><title type='text'>Boxes With Rounded Corners in CSS - Solution</title><content type='html'>&lt;p&gt;&lt;img height="113" alt="Round cornered box rendered in FireFox 1.5" src="http://www.threeleaf.com/freelance-work/demos/round-corners/images/round-corner-box-firefox-1.5.gif" width="500" alt="Image" /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;CSS Code&lt;/h2&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;.textBox {&lt;br /&gt;&amp;nbsp; &amp;nbsp; background:#9cf url(/images/question-box.gif) left top no-repeat;&lt;br /&gt;&amp;nbsp; &amp;nbsp; /* Width attribute needed to fix behavior in Internet Explorer */&lt;br /&gt;&amp;nbsp; &amp;nbsp; /* width:100%; */&lt;br /&gt;}&lt;br /&gt;.textBox .right {&lt;br /&gt;&amp;nbsp; &amp;nbsp; background:url(/images/question-box-right.gif) right top no-repeat;&lt;br /&gt;}&lt;br /&gt;.textBox .bottom {&lt;br /&gt;&amp;nbsp; &amp;nbsp; background:url(/images/question-box-bottom.gif) left bottom no-repeat;&lt;br /&gt;}&lt;br /&gt;.textBox .corner {&lt;br /&gt;&amp;nbsp; &amp;nbsp; background:url(/images/question-box-corner.gif) right bottom no-repeat;&lt;br /&gt;&amp;nbsp; &amp;nbsp; padding:1em;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2&gt;HTML Code&lt;/h2&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;&lt;br /&gt;&amp;lt;div class="textBox"&amp;gt;&amp;lt;div class="right"&amp;gt;&amp;lt;div class="bottom"&amp;gt;&amp;lt;div class="corner"&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;p&amp;gt;It is easy to create a resizable box with rounded corners using Cascading Style Sheets (CSS). Four nested &amp;amp;lt;div&amp;amp;gt; elements are required, each having a background image respectively set to the left-top corner (including the body), right edge, bottom edge, and right-bottom corner.&amp;lt;/p&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;See screenshots at &lt;a href="http://www.threeleaf.com/freelance-work/demos/round-corners/" target="_blank"&gt;http://www.threeleaf.com/freelance-work/demos/round-corners/&lt;/a&gt;&amp;nbsp;, along with some examples of why the workaround is necessary in Internet Exploer 6 and 7. My question: Why don't they fix that? If less funded browser companies like Firefox and Opera have come up with solutions, why can't Microsoft?&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-113915079371292946?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/113915079371292946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=113915079371292946' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113915079371292946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113915079371292946'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/02/boxes-with-rounded-corners-in-css.html' title='Boxes With Rounded Corners in CSS - Solution'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-113915053352438809</id><published>2006-02-05T09:41:00.000-05:00</published><updated>2006-11-30T13:36:07.183-05:00</updated><title type='text'>Formatted Date in JMeter / JavaScript - Solution</title><content type='html'>&lt;p&gt;I am using JMeter for regression testing, and needed a way to use the current date in mm/dd/yyyy format&amp;nbsp;in a form post. Here is the solution I came up with using the JavaScript function:&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;${__javaScript(d = new Date; prefix=d.getMonth()&amp;lt;9?'0':'';X = prefix + String(d.getMonth()+1) + '/' + d.getDate() + '/' + d.getFullYear(), Dummy)}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Looks like date formatting in JavaScript is a perpetual problem, so I hope this is helpful.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-113915053352438809?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/113915053352438809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=113915053352438809' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113915053352438809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113915053352438809'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/02/formatted-date-in-jmeter-javascript.html' title='Formatted Date in JMeter / JavaScript - Solution'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-113915028154946218</id><published>2006-02-05T09:36:00.000-05:00</published><updated>2006-11-30T13:38:03.423-05:00</updated><title type='text'>Microsoft Word Clears the Clipboard - Solution</title><content type='html'>&lt;p&gt;I had been using Microsoft Word for years, when suddenly I had a strange problem where if I copied text to the clipboard, then opened Word, and then attempted to paste that nothing would happen &lt;img alt="OMG!" src="http://us.i1.yimg.com/us.yimg.com/i/mesg/tsmileys2/06.gif" style="border:0px;vertical-align:bottom;" /&gt;. I have searched on the Web serveral times, but have not found a solution until now. Turns out I needed to disable a COM addin.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Thanks to Dopyiii (&lt;a href="http://howtotroubleshoot.blogspot.com/#113035503245630446"&gt;http://howtotroubleshoot.blogspot.com/#113035503245630446&lt;/a&gt;) for getting me on the right track.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;His instructions for viewing COM addins:&lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt; &lt;li&gt;Open Word and go to Tools &amp;gt; Customize &amp;gt; Commands tab&lt;br /&gt; &lt;li&gt;In the Categories section on the left, choose Tools&lt;br /&gt; &lt;li&gt;In the Commands column on the right, you'll see "COM Addins"&lt;br /&gt; &lt;li&gt;Grab this COM Addins button and drag it up and drop it off on your toolbar somewhere.&lt;br /&gt; &lt;ul&gt;&lt;br /&gt;  &lt;li&gt;It doesn't matter where - you'll delete it in a minute anyway.&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;The quick way to delete this button (or to customize the toolbar) is to hold down Alt and click and drag the button into the document. When you let go, it'll disappear!&lt;/li&gt;&lt;br /&gt; &lt;/ul&gt;&lt;br /&gt; &lt;li&gt;Close the Customize dialog&lt;br /&gt; &lt;li&gt;Now, click the new COM Addins button on your toolbar.&lt;br /&gt; &lt;ul&gt;&lt;br /&gt;  &lt;li&gt;Like the Templates and Addins dialog, you can enable or disable whatever you see here&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;Remove the button if you like, or keep it there for nostalgic purposes.&lt;/li&gt;&lt;br /&gt; &lt;/ul&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;I found that when I disabled Natural Voice Reader, I was able to paste after opening. Most people won't have NVR installed, of course, but this might also get you on the right track if it is a COM addin that is causing the problem. Let me know if this helps you!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-113915028154946218?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/113915028154946218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=113915028154946218' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113915028154946218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113915028154946218'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/02/microsoft-word-clears-clipboard.html' title='Microsoft Word Clears the Clipboard - Solution'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-113914977896541688</id><published>2006-02-05T09:26:00.000-05:00</published><updated>2006-11-30T13:41:08.270-05:00</updated><title type='text'>Spammers can exploit unvalidated PHP forms</title><content type='html'>&lt;p&gt;This is a message I sent to the AOL postmaster on September 19, 2005:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;I have recently figured out that an AOL member known as "homerragtime" has developed a method to exploit unvalidated form posts to send SPAM e-mail. For several months homerragtime was successful sending e-mail through my unvalidated forms, and I was perplexed at receiving so many rejected spams that appeared to have come from my own site.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;About two months ago I finally began validating my forms, and began to find form postings like the following being captured by my validation process:&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;pictureID aorg@johnmarshphotography.com&lt;br /&gt;comments aorg@johnmarshphotography.com&lt;br /&gt;send aorg@johnmarshphotography.com Content-Type: multipart/mixed; boundary=\"===============1010877498==\" MIME-Version: 1.0 Subject: 90c4558b To: aorg@johnmarshphotography.com bcc: homerragtime@aol.com From: aorg@johnmarshphotography.com This is a multi-part message in MIME format. --===============1010877498== Content-Type: text/plain; charset=\"us-ascii\" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit wygqm --===============1010877498==--&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The tip-off for me was seeing the BCC field. It appears homerragtime has a robot that crawls the web and posts these kinds of messages. If he gets one of the messages that he is BCCed on, he matches that with the number in his subject line, and then knows that the form can be exploited. I did a search for homerragtime, and see this same signature in many places.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Please research this further. I believe homerragtime is violating your company policy not to send spam, even though technically, he is sending the spam through other people's web sites.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;A few more notes&lt;/strong&gt;:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt; &lt;li&gt;I have found this problem has occurred on all three of the web sites I maintain. They are all fixed now.&lt;br /&gt; &lt;li&gt;My sites are all in PHP, but it is quite possible that this exploit could be used in other languages.&lt;br /&gt; &lt;li&gt;Bottom line: validate your forms. This person was very aggressive at sending out spam through my sites, judging by the large number of rejected e-mails I was getting returned to me.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-113914977896541688?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/113914977896541688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=113914977896541688' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113914977896541688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113914977896541688'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/02/spammers-can-exploit-unvalidated-php.html' title='Spammers can exploit unvalidated PHP forms'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-113914934425274978</id><published>2006-02-05T09:21:00.000-05:00</published><updated>2006-11-30T13:44:31.073-05:00</updated><title type='text'>IE Toolbar Names Get Mixed Up</title><content type='html'>&lt;p&gt;I enjoy adding toolbars to Internet Explorer (currently have nine). I do not keep them all active all the time, of course. I only keep the Google toolbar open all the time and open others as needed. However, I have noticed a problem where when I right click on the toolbar area to open or close a toolbar, the names do not always correspond to the correct toolbar. For example, clicking on Yahoo! may open or close Google. Sometimes this can get very confusing when, say, four toolbars have switched names &lt;img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/tsmileys2/20.gif" style="border:0px;vertical-align:bottom;" /&gt;.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Anyone else seen this? I have not seen it documented on the Web, and I have not figured out a solution yet.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-113914934425274978?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/113914934425274978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=113914934425274978' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113914934425274978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113914934425274978'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/02/ie-toolbar-names-get-mixed-up.html' title='IE Toolbar Names Get Mixed Up'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20432421.post-113875731335226768</id><published>2006-01-31T20:27:00.000-05:00</published><updated>2006-11-30T13:42:36.983-05:00</updated><title type='text'>Formatted Date in JMeter / JavaScript - Solution</title><content type='html'>&lt;p&gt;I am using JMeter for regression testing, and needed a way to use the current date in mm/dd/yyyy format in a form post. Here is the solution I came up with using the JavaScript function:&lt;/p&gt;&lt;br /&gt;&lt;div style="border:1px solid black;padding:5px;background:#eee;margin:5px;color:black;font-family:Courier New,Courier,monospace;text-align:left;"&gt;${__javaScript(d = new Date; prefix=d.getMonth()&lt;9?'0':'';X = prefix + String(d.getMonth()+1) + '/' + d.getDate() + '/' + d.getFullYear(), Dummy)}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Looks like date formatting in JavaScript is a perpetual problem, so I hope this is helpful.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20432421-113875731335226768?l=zavyn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zavyn.blogspot.com/feeds/113875731335226768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20432421&amp;postID=113875731335226768' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113875731335226768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20432421/posts/default/113875731335226768'/><link rel='alternate' type='text/html' href='http://zavyn.blogspot.com/2006/01/formatted-date-in-jmeter-javascript.html' title='Formatted Date in JMeter / JavaScript - Solution'/><author><name>John</name><uri>http://www.blogger.com/profile/13049348817363904229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://www.threeleaf.com/assets/images/miscellaneous/john.headshot.closeup.jpg'/></author><thr:total>1</thr:total></entry></feed>
