{"id":156,"date":"2005-06-26T10:36:06","date_gmt":"2005-06-26T13:36:06","guid":{"rendered":"http:\/\/www.hoogervorst.ca\/arthur\/?p=156"},"modified":"2005-06-26T21:21:36","modified_gmt":"2005-06-27T00:21:36","slug":"no-not-yet-another-find-tool","status":"publish","type":"post","link":"http:\/\/www.hoogervorst.ca\/arthur\/?p=156","title":{"rendered":"No! Not Yet Another Find Tool!"},"content":{"rendered":"<p><span class=\"dropcap\">H<\/span>ey. <img src='.\/wp-content\/fandro.jpg' alt='No Not Another Find Tool' style=\"float:right;margin:5px\" \/>I didn&#8217;t break it this time!\n<\/p>\n<p>Earlier this year, I rambled about Windows XP not-so-good internal text search tool: It&#8217;s broken. No matter how you try to find files with specific portions of text, it will not return the right results. No matter if you turn that frigging dog off (&#8216;Assistant, my *ss&#8217;), it will not return the files I&#8217;m looking for. I know they&#8217;re there. I wonder if this is the reason why other companies saw a hole in the market for an invention that was supposed to be there: <strong>the Desktop Search Tool!<\/strong> And Microsoft (as you&#8217;ve probably found out) has now also launched their own tool, appropriately called <a href=\"http:\/\/toolbar.msn.com\/desktop\/results.aspx?FORM=PCHP&#038;q=\">&#8216;Desktop Search&#8217;<\/a>. Why did they break it in XP anyways? Can I sue them now? I mean, I just want to find my files.\n<\/p>\n<p>Also, while looking around for other tools, I found that most of them were &#8216;light versions&#8217; (Agent Ransack for example) or bluntly said, <em>overpriced<\/em>. And while Grep works on Windows (using the GNU tools for Windows), it doesn&#8217;t find me  files with specific timestamps and creation dates.\n<\/p>\n<p><!--more--><\/p>\n<p>Since it was about time to sharpen my algorithm skills, I delved into search routines, studied the Boyer Moore Horspool algorithm and ended up with a quick and dirty search tool. I made a couple of mistakes first. I thought it was smart to use Delphi&#8217;s internal objects to load files, but I quickly found out that they&#8217;re limited: for example trying to load a 500 MB AVI file (&#8216;Wing Commander&#8217;) ended up bombing out on me (the movie was a bomb anyways, but that&#8217;s a different story). I decided to change plans radically and chose for the use of Windows memory-mapped files, which meant I had to jump back to Delphi&#8217;s Pchars (&#8216;pointer to chars&#8217;).\n<\/p>\n<p>Here&#8217;s where the story becomes interesting and where all the logic of Pascal seems to fade away: who decided to have strings start at character 1? (If I remember correctly, the first character in a Pascal string is a pointer to the length of the string). While changing my code to understand pointers and pchars, I ran in an overflow in a while loop, a loop that literally frequently tests if a specific variable has reached until the end of the buffer or (in my case originally) the string. It looks something like this:\n<\/p>\n<p><code><br \/>\n   while fPos < = textlenght do\n   begin\n      The Code....\n   end;\n<\/code><br \/>\n<\/code><\/p>\n<p>This works perfect for normal strings: lets say, we have a string with a length of 255 characters. Since our first character starts at 1, telling a loop to continue until we have reached a value smaller or equals works great. Can you tell where the problems start when you work with 0 based arrays and buffers? (hint: 0 + 255 == 254)\n<\/p>\n<p>Building your own software gives you the right to call it whatever you want to call it: I opted to go for &#8220;Fandro&#8221; which means something like &#8216;Vander <em>what<\/em>?&#8217;, the answer some people get when they pronounced their Dutch lastname (also note the appropriate use of Italics). Or maybe just maybe Fandro is  a wordplay on the words of a certain Commander in Chief who proclaimed that &#8216;major combat operations are over&#8217;. Except for files then, naturally: Because the irony of everything is that, while you may think you&#8217;ve finally got it working again, it ends up <em>broken<\/em> anyways. Or rather, when you think you have found that darn file, you end up deleting it anyways!\n<\/p>\n<p>Fandro will be offered as Freeware on xsamplex whenever I think it&#8217;s time to throw it out.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey. I didn&#8217;t break it this time! Earlier this year, I rambled about Windows XP not-so-good internal text search tool: It&#8217;s broken. No matter how you try to find files with specific portions of text, it will not return the &hellip; <a href=\"http:\/\/www.hoogervorst.ca\/arthur\/?p=156\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=\/wp\/v2\/posts\/156"}],"collection":[{"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=156"}],"version-history":[{"count":0,"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=\/wp\/v2\/posts\/156\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}