<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bc-programming.com &#187; Programming</title>
	<atom:link href="http://bc-programming.com/blogs/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://bc-programming.com/blogs</link>
	<description>Programming, Possums, and why you shouldn&#039;t mix the two.</description>
	<lastBuildDate>Thu, 29 Jul 2010 07:24:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=6010</generator>
		<item>
		<title>Parsing INI Files</title>
		<link>http://bc-programming.com/blogs/2010/07/parsing-ini-files/</link>
		<comments>http://bc-programming.com/blogs/2010/07/parsing-ini-files/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 07:24:03 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=234</guid>
		<description><![CDATA[If there is one thing that no two Operating Systems can seem to agree on, it&#8217;s how best to store configuration information. Linux programs generally store their configuration in .config files, which have a, ironically enough, &#8220;proprietary&#8221; text format (that is, program A&#8217;s config file will be unlikely to follow the same conventions as program [...]]]></description>
			<content:encoded><![CDATA[<p>If there is one thing that no two Operating Systems can seem to agree on, it&#8217;s how best to store configuration information. Linux programs generally store their configuration in .config files, which have a, ironically enough, &#8220;proprietary&#8221; text format (that is, program A&#8217;s config file will be unlikely to follow the same conventions as program B&#8217;s, and so forth). For Windows, there are a lot of options to choose from. the earliest model was a INI, or initialization file; an INI file was laid out something like this:</p>
<p><code><br />
[sectionname]<br />
valuename=value<br />
valuename2=value2<br />
[nextsection]<br />
morevalues=moreitems<br />
evenmorevalues=evenmoredata<br />
</code></p>
<p>Basically, it consisted of a set of &#8220;Sections&#8221; (the text in square brackets) each of which contained values (the name/value pairs within).</p>
<h3><u>WriteProfileString, ReadProfileString, WritePrivateProfileString and ReadPrivateProfileString</u></h3>
<p>
The two &#8220;private&#8221; variants of this Kernel32 function almost always appear in programming-oriented discussions about INI files, but the former two have been lost in time.</p>
<p>the &#8220;INI&#8221; file structure was essentially &#8220;standardized&#8221; as far as windows applications were concerned with Windows 3.0. This was more a de facto, rather then a de juere standard, because the win.ini, system.ini, and various other Windows system based &#8220;ini&#8221; files used that form. Windows 3.0 offered the WriteProfileString and ReadProfileString functions. These functions are still present, even in the windows 7 Version of kernel32.dll:</p>
<p><code><br />
C:\Windows\System32>dumpbin /exports kernel32.dll | find "ProfileString"<br />
        579  241 0001E6A7 GetPrivateProfileStringA<br />
        580  242 0003018B GetPrivateProfileStringW<br />
        606  25C 00032B13 GetProfileStringA<br />
        607  25D 00031E72 GetProfileStringW<br />
       1323  52A 00033FB8 WritePrivateProfileStringA<br />
       1324  52B 000335CA WritePrivateProfileStringW<br />
       1330  531 0008A982 WriteProfileStringA<br />
       1331  532 00033669 WriteProfileStringW<br />
</code></p>
<p>the non- &#8220;private&#8221; versions of these functions were pretty similar; there were also variations that allowed for writing/reading directly from integers as well as entire structures. Windows 3.0 only had the &#8220;non&#8221; private versions- and they all dealt exclusively with win.ini.</p>
<p>So, using WriteProfileString in kernel.dll, you could save your applications configuration data to and read it from a section in win.ini. This would have worked fine, with the minor inconvenience of a large win.ini file, but there was a caveat- the functions could not work with an INI file larger then 64K.</p>
<p>So, this technical limitation combined with the aftertaste of having a win.ini file that even comes near to approaching 64K guided the implementation of the &#8220;private&#8221; versions of these functions. These took, in addition to the values that the older functions did, a parameter specifying a filename. So now, applications could read and write values and sections to their own &#8220;private profile&#8221; INI files (thus the name). They still had the 64K limit, but this is hardly ever approached.</p>
<p>Fast forward a few years, and we have the Windows Registry. This is where Microsoft encourages us to save our application specific data. And I won&#8217;t argue- it works great. There is of course a minor caveat- it&#8217;s not as &#8220;user editable&#8221; as an INI file. if you ask somebody &#8220;change such and such value in program.ini&#8221; to solve a problem, they will usually have no problem, but ask them to change values in the registry and your asking for trouble, first- they could change the wrong value (after all, it&#8217;s pretty much a hierarchal version of the old win.ini, but without a size limitation), second, it&#8217;s not as &#8220;discoverable&#8221;. you can open an INI file, change it, make backups, etc. You can do this with a registry key but it&#8217;s not as simple and intuitive. backups involve exporting .reg files.</p>
<p>Now, with .NET, we are being encouraged to save our data into XML files. Are we not now back where we started? we started with text based INI files, moved to a monolithic binary hierarchal database, and we are now back to a text based format. The only real difference between INI and XML is the fact that XML is inherently heirarchal, so it&#8217;s easier to make code that works with either XML or the registry without problems. INI is limited to a fixed structure where there are two layers- the sections, and the values.</p>
<p>In either case, sometimes for a simple application there is no need to get involved in either the registry or XML; or, maybe you just like the simplicity and user-editability of an INI file. This is why I use INI files for most of my applications.</p>
<p>Given the fact that we have the API functions to work with INI files, you might think that my class-based solution may use them. This is not the case. you see, first, they are deprecated- second, they are limited to 64K, and lastly, and perhaps most importantly, they can sometimes not even read INI files at all- thanks to the fact that their functionality will often look in the registry for data. (this establishes it quite loudly as a compatibility function, not something to depend on for modern applications).</p>
<p>Instead, I opted to create a INI file parser. Thankfully, because of the simple structure it&#8217;s not hard to create something like this.</p>
<p>First, we need to think of an appropriate object model. we have sections, values, and the INI file itself. the base-level representation should be an abstract class that sections, and values can derive from:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; public abstract class INIItem</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public abstract override <span class="kw4">String</span> ToString<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>you may be thinking, &#8220;why make an abstract class?&#8221; well, consider for a moment, comments, in the INI file. by convention, an INI file can have comments inside it, indicated by a semicolon as the first non-space character on the line. We <i>could</i> simply discard them entirely, but ideally, we would preserve the comments between loading the INI file and saving it. Here, we can create a derived class representing a comment:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;public class INIComment : INIItem</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">String</span> Comment <span class="br0">&#123;</span>get;set;<span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; public INIComment<span class="br0">&#40;</span><span class="kw4">String</span> pComment<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Comment = pComment;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public override <span class="kw4">string</span> ToString<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> Comment;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>the Section itself can contain a list of INIItem objects, which can represent either INIComment or an INIDataItem, which is shown here:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;public class INIDataItem : INIItem</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">String</span> Name <span class="br0">&#123;</span> get; set; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">String</span> Value <span class="br0">&#123;</span> get; set; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public override <span class="kw4">string</span> ToString<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> Name + <span class="st0">&quot;=&quot;</span> + Value;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>At this point, I have decided that it would make sense to Load the INI file entirely into memory. INI files are usually small in size, and considering the convention with XML files is to keep the XMLDocument in memory it&#8217;s not that new of an approach.</p>
<p>Now, we need a INISection class; this will be used to represent each Section in an INI file; It needs a Name, a list of Values, and a &#8220;eolComment&#8221; (end of line comment) for when there is a comment on the same line.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;public class INISection</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public List&lt;INIItem&gt; INIItems;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">String</span> Name <span class="br0">&#123;</span> get; set; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">String</span> eolComment <span class="br0">&#123;</span> get; set; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public INISection<span class="br0">&#40;</span><span class="kw4">String</span> pName, <span class="kw4">string</span> peolComment, List&lt;INIItem&gt; Values<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Name = pName;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INIItems = Values;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>peolComment == <span class="kw2">null</span><span class="br0">&#41;</span> peolComment = <span class="st0">&quot;&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eolComment = peolComment;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public INIDataItem this<span class="br0">&#91;</span><span class="kw4">String</span> index<span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INIDataItem returnthis =</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getValues<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">FirstOrDefault</span><span class="br0">&#40;</span><span class="br0">&#40;</span>w<span class="br0">&#41;</span> =&gt; w.<span class="me1">Name</span>.<span class="me1">Equals</span><span class="br0">&#40;</span>index, StringComparison.<span class="me1">OrdinalIgnoreCase</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>returnthis == <span class="kw2">null</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//returnthis = new INISection(index, null, new List&lt;INIItem&gt;());</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnthis = new INIDataItem<span class="br0">&#40;</span>index, <span class="st0">&quot;&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INIItems.<span class="me1">Add</span><span class="br0">&#40;</span>returnthis<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> returnthis;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//remove any existing value with the given name&#8230;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INIItem itemfound =</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getValues<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">FirstOrDefault</span><span class="br0">&#40;</span>w =&gt; w.<span class="me1">Name</span>.<span class="me1">Equals</span><span class="br0">&#40;</span>index, StringComparison.<span class="me1">OrdinalIgnoreCase</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>itemfound != <span class="kw2">null</span><span class="br0">&#41;</span> INIItems.<span class="me1">Remove</span><span class="br0">&#40;</span>itemfound<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INIItems.<span class="me1">Add</span><span class="br0">&#40;</span>value<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public IEnumerable&lt;inidataitem&gt; getValues<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach <span class="br0">&#40;</span>INIItem loopitem in INIItems<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INIDataItem casted = loopitem as INIDataItem;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>casted != <span class="kw2">null</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yield <span class="kw1">return</span> casted;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public override <span class="kw4">string</span> ToString<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="st0">&quot;[&quot;</span> + Name + <span class="st0">&quot;] (&quot;</span> + getValues<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">Count</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">ToString</span><span class="br0">&#40;</span><span class="br0">&#41;</span> + <span class="st0">&quot; Values, &quot;</span> +</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#40;</span>INIItems.<span class="me1">Count</span><span class="br0">&#40;</span><span class="br0">&#41;</span> &#8211; getValues<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">Count</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>.<span class="me1">ToString</span><span class="br0">&#40;</span><span class="br0">&#41;</span> + <span class="st0">&quot; Comments.&quot;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>Now this can appear a bit more daaunting then it really is. The bulk of the code is in the indexer, which allows you to modify an INI file like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">INIFile myini= new INIFile<span class="br0">&#40;</span>INIFilename<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">myini<span class="br0">&#91;</span><span class="st0">&quot;section&quot;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;value&quot;</span><span class="br0">&#93;</span>.<span class="me1">Value</span>=<span class="st0">&quot;a new value&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">Configurationsettions.<span class="me1">UseLongformat</span>=myini<span class="br0">&#91;</span><span class="st0">&quot;formatting&quot;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;uselongformat&quot;</span><span class="br0">&#93;</span>.<span class="me1">Value</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
</ol>
</div>
<p>It&#8217;s actually a lot shorter then it would have been had I not used lambda expressions:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;INIDataItem returnthis =</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getValues<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">FirstOrDefault</span><span class="br0">&#40;</span><span class="br0">&#40;</span>w<span class="br0">&#41;</span> =&gt; w.<span class="me1">Name</span>.<span class="me1">Equals</span><span class="br0">&#40;</span>index, StringComparison.<span class="me1">OrdinalIgnoreCase</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>first, this is operating on the IEnumerable being given back from getValues(); getValues is what is known as an iterator method, a simplified way to think of it is that the return value is a set of all the values that were &#8220;yield returned&#8221; from that function. In this case, getValues() returns all the items that can be cast to an INIDataItem. This ensures that the lambda expression used with FirstOrDefault() has access to the Name field to perform the appropriate comparison.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; public class INIFile</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public List&lt;INISection&gt; Sections <span class="br0">&#123;</span> get; set; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public INIFile<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sections = new List&lt;INISection&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public INIFile<span class="br0">&#40;</span><span class="kw4">String</span> filename<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LoadINI<span class="br0">&#40;</span>filename<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Indexer&#8230;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public INISection this<span class="br0">&#91;</span><span class="kw4">String</span> index<span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INISection returnthis =</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sections.<span class="me1">FirstOrDefault</span><span class="br0">&#40;</span><span class="br0">&#40;</span>w<span class="br0">&#41;</span> =&gt; w.<span class="me1">Name</span>.<span class="me1">Equals</span><span class="br0">&#40;</span>index, StringComparison.<span class="me1">OrdinalIgnoreCase</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>returnthis == <span class="kw2">null</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnthis = new INISection<span class="br0">&#40;</span>index, <span class="st0">&quot;&quot;</span>, new List&lt;INIItem&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sections.<span class="me1">Add</span><span class="br0">&#40;</span>returnthis<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> returnthis;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//remove any existing value with the given name&#8230;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INISection itemfound =</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sections.<span class="me1">FirstOrDefault</span><span class="br0">&#40;</span>w =&gt; w.<span class="me1">Name</span>.<span class="me1">Equals</span><span class="br0">&#40;</span>index, StringComparison.<span class="me1">OrdinalIgnoreCase</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>itemfound != <span class="kw2">null</span><span class="br0">&#41;</span> Sections.<span class="me1">Remove</span><span class="br0">&#40;</span>itemfound<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sections.<span class="me1">Add</span><span class="br0">&#40;</span>value<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; private <span class="kw4">static</span> INIDataItem ParseINIValue<span class="br0">&#40;</span><span class="kw4">String</span> valueline<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> equalspos = valueline.<span class="me1">IndexOf</span><span class="br0">&#40;</span><span class="st0">&#8216;=&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">String</span> valuename = <span class="st0">&quot;&quot;</span>, valuedata = <span class="st0">&quot;&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>equalspos == <span class="nu0">-1</span><span class="br0">&#41;</span> <span class="kw1">return</span> <span class="kw2">null</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; valuename = valueline.<span class="me1">Substring</span><span class="br0">&#40;</span><span class="nu0">0</span>, equalspos<span class="br0">&#41;</span>.<span class="me1">Trim</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; valuedata = valueline.<span class="me1">Substring</span><span class="br0">&#40;</span>equalspos + <span class="nu0">1</span><span class="br0">&#41;</span>.<span class="me1">Trim</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> new INIDataItem<span class="br0">&#40;</span>valuename, valuedata<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">void</span> LoadINI<span class="br0">&#40;</span><span class="kw4">String</span> Filename<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; using <span class="br0">&#40;</span>var newreader = new StreamReader<span class="br0">&#40;</span>File.<span class="me1">OpenRead</span><span class="br0">&#40;</span>Filename<span class="br0">&#41;</span>, <span class="kw2">true</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LoadINI<span class="br0">&#40;</span>newreader<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newreader.<span class="me1">Close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">void</span> LoadINI<span class="br0">&#40;</span><span class="kw4">String</span> Filename, Encoding pEncoding<span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; using <span class="br0">&#40;</span>var newreader = new StreamReader<span class="br0">&#40;</span>File.<span class="me1">OpenRead</span><span class="br0">&#40;</span>Filename<span class="br0">&#41;</span>, pEncoding<span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LoadINI<span class="br0">&#40;</span>newreader<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newreader.<span class="me1">Close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">void</span> LoadINI<span class="br0">&#40;</span>StreamReader fromstream<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">String</span> currentline = <span class="kw2">null</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sections = new List&lt;INISection&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INISection globalsection = new INISection<span class="br0">&#40;</span><span class="st0">&quot;cINIFilecsGlobals&quot;</span>, <span class="st0">&quot;&quot;</span>, new List&lt;INIItem&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INISection currentSection = globalsection;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//while there is still text to read.</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>currentline = fromstream.<span class="me1">ReadLine</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> != <span class="kw2">null</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//trim the read in line&#8230;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentline = currentline.<span class="me1">Trim</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//if it starts with a square bracket, it&#8217;s a section.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>currentline.<span class="me1">StartsWith</span><span class="br0">&#40;</span><span class="st0">&quot;[&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//parse out the section name...</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">String</span> newsectionname = currentline.<span class="me1">Substring</span><span class="br0">&#40;</span><span class="nu0">1</span>, currentline.<span class="me1">IndexOf</span><span class="br0">&#40;</span><span class="st0">']&#8216;</span><span class="br0">&#41;</span> &#8211; <span class="nu0">1</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">String</span> eolComment = <span class="st0">&quot;&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>currentline.<span class="me1">IndexOf</span><span class="br0">&#40;</span><span class="st0">&#8216;;&#8217;</span><span class="br0">&#41;</span> &gt; <span class="nu0">-1</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eolComment = currentline.<span class="me1">Substring</span><span class="br0">&#40;</span>currentline.<span class="me1">IndexOf</span><span class="br0">&#40;</span><span class="st0">&#8216;;&#8217;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentSection = new INISection<span class="br0">&#40;</span>newsectionname, eolComment, new List&lt;INIItem&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sections.<span class="me1">Add</span><span class="br0">&#40;</span>currentSection<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span>currentline.<span class="me1">StartsWith</span><span class="br0">&#40;</span><span class="st0">&quot;;&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//add a new Comment INIItem to the current section.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INIItem newitem = new INIComment<span class="br0">&#40;</span>currentline<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentSection.<span class="me1">INIItems</span>.<span class="me1">Add</span><span class="br0">&#40;</span>newitem<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INIDataItem createitem = ParseINIValue<span class="br0">&#40;</span>currentline<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>createitem != <span class="kw2">null</span><span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentSection.<span class="me1">INIItems</span>.<span class="me1">Add</span><span class="br0">&#40;</span>createitem<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>globalsection.<span class="me1">INIItems</span>.<span class="me1">Count</span><span class="br0">&#40;</span><span class="br0">&#41;</span> &gt; <span class="nu0">0</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sections.<span class="me1">Add</span><span class="br0">&#40;</span>globalsection<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">void</span> SaveINI<span class="br0">&#40;</span><span class="kw4">String</span> filename<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; using <span class="br0">&#40;</span>StreamWriter swriter = new StreamWriter<span class="br0">&#40;</span>File.<span class="me1">OpenWrite</span><span class="br0">&#40;</span>filename<span class="br0">&#41;</span>, Encoding.<span class="me1">ASCII</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SaveINI<span class="br0">&#40;</span>swriter<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; swriter.<span class="me1">Close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">void</span> SaveINI<span class="br0">&#40;</span><span class="kw4">String</span> filename, Encoding pEncoding<span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; using <span class="br0">&#40;</span>StreamWriter swriter = new StreamWriter<span class="br0">&#40;</span>File.<span class="me1">OpenWrite</span><span class="br0">&#40;</span>filename<span class="br0">&#41;</span>, pEncoding<span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SaveINI<span class="br0">&#40;</span>swriter<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; swriter.<span class="me1">Close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">void</span> SaveINI<span class="br0">&#40;</span>StreamWriter tostream<span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//save to the given stream.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach <span class="br0">&#40;</span>INISection loopsection in Sections<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//don&#8217;t write out &quot;[global]&quot; for the global section, if present.</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>!loopsection.<span class="me1">Name</span>.<span class="me1">Equals</span><span class="br0">&#40;</span><span class="st0">&quot;cINIFilecsGlobals&quot;</span>, StringComparison.<span class="me1">OrdinalIgnoreCase</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tostream.<span class="me1">Write</span><span class="br0">&#40;</span><span class="st0">&quot;[&quot;</span> + loopsection.<span class="me1">Name</span> + <span class="st0">&quot;]&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>loopsection.<span class="me1">eolComment</span>.<span class="me1">Length</span> &gt; <span class="nu0">0</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tostream.<span class="me1">WriteLine</span><span class="br0">&#40;</span><span class="st0">&quot; &nbsp;&quot;</span> + loopsection.<span class="me1">eolComment</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tostream.<span class="me1">WriteLine</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach <span class="br0">&#40;</span>INIItem itemloop in loopsection.<span class="me1">INIItems</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tostream.<span class="me1">WriteLine</span><span class="br0">&#40;</span>itemloop.<span class="me1">ToString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
</ol>
</div>
<p>And that&#8217;s the INIFile. the INIFile itself has a Indexer similiar to what  the INISection class has, but it deals with the list of Sections. relatively straightforward, for the most part. LoadINI and SaveINI are both overloaded with a few different parameters, from passing in a StreamReader/Writer to simply giving a filename. For reading in an INI file into a class structure we simply read every line (the while ((currentline = fromstream.ReadLine()) != null) loop ) and take an appropriate action based on what we find- if it starts with a square bracket, it&#8217;s treated as a section. a new section is added with that name, and the local variable &#8220;currsection&#8221; is changed to point to it. if it starts with a semicolon it is treated as a comment (and an appropriate INIComment object is added to the INISection pointed at by currsection, which by default is an imaginary &#8220;global&#8221; section). Otherwise if there is an equals sign in the line, it is parsed (using the ParseINIValue() function) into a appropriate INIValue object, and that object is added to the current section.</p>
<p>writing it back into a stream is pretty much the opposite; loop through all the sections, and for every section, if the name is not the globally defined intrinsic item, then write out the appropriate section header (the name in square brackets), as well as any end of line comment defined for that section. then loop through all the values and write out the ToString() from it as a single line. (remember, the INIComment will return a comment line (starting with <img src='http://bc-programming.com/blogs/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  and the INIDataItem object will return a properly constructed Name=Value string.</p>
<p>The Full Source can be downloaded here:</p>
<p><a href="http://bc-programming.com/downloads/files/Code/cINIFile.cs">CINIFile.cs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2010/07/parsing-ini-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YA2012P (Yet another 2012 Post)</title>
		<link>http://bc-programming.com/blogs/2010/07/ya2012p-yet-another-2012-post/</link>
		<comments>http://bc-programming.com/blogs/2010/07/ya2012p-yet-another-2012-post/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 21:51:00 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=183</guid>
		<description><![CDATA[Alright, so I sort of touched on this subject before, but I feel I need to revisit it for no reason. Also, because I can do whatever I damn well please. Now, as you are no doubt aware, there is quite a furor about &#8220;the end of the world&#8221;&#8230; well, more precisely, there was. as [...]]]></description>
			<content:encoded><![CDATA[<p>Alright, so I sort of touched on this subject <a href="http://bc-programming.com/blogs/2010/03/how-2012-type-crap-starts/">before</a>, but I feel I need to revisit it for no reason. Also, because I can do whatever I damn well please.</p>
<p>Now, as you are no doubt aware, there is quite a furor about &#8220;the end of the world&#8221;&#8230; well, more precisely, there was. as 2012 approaches it appears that they are changing their tune &#8220;well, it won&#8217;t be the end, but everything will change!&#8221;.</p>
<p>For &#8220;facts&#8221; proponents refer to the mayans, Nostradamus, and the bible.</p>
<p>for Facts.</p>
<p>please, tell me they aren&#8217;t serious?</p>
<p>First, they claim that the Mayans &#8220;knew&#8221; there was going to be a major change in our history. How? magic? Did a people who couldn&#8217;t even master the length of the solar year actually have somehow mastered time travel and seeing into the future? No. Of course not. Sure, their civilization was advanced, but if they couldn&#8217;t predict their civilizations own death I really don&#8217;t think it&#8217;s very smart to  believe any of their &#8220;predictions&#8221; (did anybody account for the fact that their solar calendar was busted, anyway?).</p>
<p>And don&#8217;t get me started on Nostradamus. Biggest phony ever. &#8220;hey, guys, I have an idea, I&#8217;ll write down completely meaningless gibberish and say it&#8217;s prophecy, and people will believe it and connect the dots for me.&#8221;</p>
<p>The sad thing is nobody sees it! They are purposely vague not because &#8220;he didn&#8217;t understand today&#8217;s technology or the various changes that he &#8220;saw&#8221;" but rather because if he was specific they would be wrong.</p>
<p>The fact that any otherwise reasonable human being with a solid understanding of either physics or the nature of space can even give any sort of creedence to an obvious fake and even go so far as to evangelize his name (well, if he predicted it, it&#8217;ll come true).</p>
<p>Except he didn&#8217;t predict anything! That&#8217;s the problem I have with it. If I wrote down that in 2013:</p>
<p>a great power will rise. Many will be killed.<br />
The Koala bear roams free. eucalyptus suffers.<br />
Olives drop. All dead. Great bird eats grapes for breakfast.</p>
<p>And enough people believed it &#8220;it would happen&#8221; not because I predicted it, but the very vague nature of the words opens them up to so many interpretations that during the course of the year it&#8217;s certain that there is a timeline that could fit this random gibberish. This doesn&#8217;t even touch on the fact that the man was french, so all of these predictions are translated. I decided to do a little digging, namely about his &#8220;power&#8221; to predict world events; for example, here is the original french passage that &#8220;predicted world war 2&#8243;:</p>
<blockquote><p>
    Bêtes farouches de faim fleuves tranner;<br />
    Plus part du champ encore Hister sera,<br />
    En caige de fer le grand sera treisner,<br />
    Quand rien enfant de Germain observa. (II.24)
</p></blockquote>
<p>Now, according to the website I originally found this the translation of this to english was:</p>
<blockquote><p>
Beasts wild with hunger will cross the rivers,<br />
The greater part of the battle will be against Hitler.<br />
He will cause great men to be dragged in a cage of iron,<br />
When the son of Germany obeys no law.
</p></blockquote>
<p>Note <specifically> how names and places are mentioned quite clearly. But this is a biassed translation- the translator restricted an otherwise vague quatrain to fit his own purposes. The literal translation is:</p>
<blockquote><p>
Beasts mad with hunger will swim across rivers,<br />
Most of the army will be against the Lower Danube.<br />
The great one shall be dragged in an iron cage<br />
When the child brother will observe nothing.
</p></blockquote>
<p>As with any of his passages, and even his strongest proponents agree &#8220;his predictions only become crystal clear after they have occured&#8221;.</p>
<p>What the fuck kind of use is that? &#8220;Oh, he can predict the future, but we can only know what it means after it happens&#8221; So, basically, he purposely phrased his quatrains in a vague, completely meaningless way and as I said those who want to are able to give meaning to any passage. It&#8217;s really quite simple, and the fact that people actually believe this utter and complete bullshit is beyond me. Not to mention they even go so far as to invent propesized events- apparently he predicted 9/11, but he didn&#8217;t. the entire thing was a hoax. So the real question is how many of his &#8220;predictions&#8221; are either biassed translations or completely fabrications? I find it interesting because a large quantity of his &#8220;followers&#8221; can&#8217;t even read french.</p>
<p>This is a rather similar case as with the bible itself. Now, I have no problem with Christians of course, and the bible certainly contains words that anybody can live by.</p>
<p>But it&#8217;s a spiritual guidebook, not a prophetic gypsy book. The problem is the bloody thing has been translated and re-translated that even if the original was in some way &#8220;the word of god&#8221; it&#8217;s become so mangled and filtered by so many people translating it between different languages that it&#8217;s only natural for some parts to lose cohesion.</p>
<p>It, just like most &#8220;predictions&#8221; is also rather vague, using symbolic imagery to try to pain a picture of the future (in those parts people claim it does that).</p>
<p>Now, the problem here is that the only place that &#8220;symbolic imagery&#8221; and &#8220;predictions&#8221; should ever be used in the same sentence is when you are referring to the horoscopes in a newspaper. No reasonable person is going to read a horoscope for their sign that says:</p>
<blockquote><p>
There could be some friction in your place of work or group gathering today, and it will be up to you to take the middle ground. Pay attention to the minor details in connection with a major project, because it&#8217;s the little things that will make the final picture work.
</p></blockquote>
<p>and actually believe it (well, nobody who is completely sane, anyway) because it&#8217;s often wrong and it&#8217;s sufficiently vague it could apply to nearly anything. and if you add the fact that desperate times calls for creating new meanings for literal words&#8230; for example, a die-hard advocate, upon seeing that t his has absolutely no relevance to anything whatsoever might try to say &#8220;well, maybe the friction represents&#8230;&#8221; or &#8220;by &#8220;middle ground&#8221; they must mean&#8230;</p>
<p>it&#8217;s all a load of smoke and mirrors and it&#8217;s the fact that these people understand, either conciously or sub-consciously, how the human mind has an arcane, even magical, ability to fill in the blanks and create connections where there are none. It&#8217;s really no more then a optical illusion with ideas and words. When you see the classic optical illusion whereby two images of the same size are placed on a perspective plane, do you truly believe that the object that appears larger (because it is &#8220;farther back&#8221;) is really larger?</p>
<p>No, of course not. Once you remove the backdrop of the perspective line and vanishing point the entire thing is clearly not as it seems. So too can people cleverly insert &#8220;perspective lines&#8221; in our very own perceptions of words. Just as our Visual Cortex fills in many blanks for us when there isn&#8217;t enough information, or as part of our perceptions (for example, our perception of contrast, colour, and so forth, can be changed by merely introducing a few lines, just as the way an entire scene looks can be changed by introducing a single element. So too does our mind &#8220;fill in the blanks&#8221; for many other topics. More precisely, we see what isn&#8217;t there because we <b>want</b> to see what isn&#8217;t there.</p>
<p>Many people have capitalizee on this.</specifically></p>
]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2010/07/ya2012p-yet-another-2012-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The deadly Microconda snake</title>
		<link>http://bc-programming.com/blogs/2010/07/the-deadly-microconda-snake/</link>
		<comments>http://bc-programming.com/blogs/2010/07/the-deadly-microconda-snake/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 11:57:40 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=148</guid>
		<description><![CDATA[I previous discussed the dangers of the deadly giant Earthworm. Recently, a new discovery has been made, the tiny Anaconda, which has been dubbed the &#8220;MicroConda&#8221;. This is a force to be reckoned with. The Life cycle of the Microconda consists of the following phases: First, they are born as a sort of virus. Microscopic [...]]]></description>
			<content:encoded><![CDATA[<p>I previous discussed the dangers of the deadly <a href="http://bc-programming.com/blogs/2010/01/the-greatest-threat-to-mankind/">giant Earthworm</a>. Recently, a new discovery has been made, the tiny Anaconda, which has been dubbed the &#8220;MicroConda&#8221;.</p>
<p>This is a force to be reckoned with. The Life cycle of the Microconda consists of the following phases:</p>
<p>First, they are born as a sort of virus. Microscopic in size, and they infect bacteria that live in a mammal&#8217;s intestines. The bacteria don&#8217;t die, but the MicroConda Larvae virus infiltrates the cell nucleus and changes the mitocondrial DNA to collect phosporus from the bloodstream. This is used and combined to create a photosensitive mitochondria. The virus then uses it&#8217;s powers of nucleic persuasion to do this to two mitochondria, forming eyes. A side effect (and therefore a symtom of microCondal infection) is that all excrement from the mammal will glow bright Orange. Once the infected bacteria are released in this fashion,they seep into the ground where they are ingested by tree roots. Through a process known as osmosis, the tree sap (as well as the infected/mind-controlled bacteria) finds it&#8217;s way to the forest canopy, and finds it&#8217;s way into a leaf.At this point, the larvae form simply waits until a leaf-miner caterpillar eats it. It infects the caterpillar and reprograms it so that it eats almost three times as fast as your standard leaf-miner. At the same time, it reprograms the DNA instructions that will be &#8220;executed&#8221; when the caterpillar enters it&#8217;s chrysalis. The leaf-miner, due to it&#8217;s larger intake of food grows to epic proportions, to the point where it is nearly 3 feet long. Since this is readily visible to predators, the virus creates a networked computer system inside the caterpillar, using the caterpillars organs as a sort of Bio-Nemetic processor. Using this, it also puts up a meta-phasic shield around the caterpillar, which turns any predator within 3 feet of it into a flaming mess.</p>
<p>At this point, the larvae sets a course for the most stable branch of the tree, and begins the reconfiguration process by initiating the formation of a chrysalis. During this time, the larvae has created a sort of replicator technology and protects the chrysalis using a metal alloy, in addition to the shields described earlier.</p>
<p>During the reconfiguration process, the larvae reconfigures the caterpillar slightly so that instead of forming a butterfly, it creates a small interstellar spacecraft that is capable of faster then light travel (easier then it sounds really, in fact the butterflies as they are today are really a result of a cosmic ray that hit one of the first evolved caterpillars and knocked it&#8217;s gene sequence out of whack, so that they all have the &#8220;do not form a interstellar light-speed capable starship&#8221; gene.). Once the larvae emerges in it&#8217;s newfound starship, it spends exactly 13 nights hovering around the globe in front of very drunk and paranoid people, as well as those who like to form UFO conspiracy theories, knowing full well that not only will they think they were much larger then they were but also that they were real starships.</p>
<p>After the 13-day rest, the larvae sets course for Mars, where it sits dormant in the Martian soil in order to confuse scientists. It makes a deliberate effort to try to be scooped up in any Rovers that come by, in an attempt to further confuse people about wether there is life on Mars. After (usually in vain) waiting there for another 13 years, the Larvae (yes, it&#8217;s still a larvae) powers up it&#8217;s Engines and sets course away from Earth. This is where the cycle get&#8217;s confusing- Nobody really knows what happens to it, but it always returns on Memorial Day 15 years later at exactly 10:00 PM GMT, which is the exact time Oprah is on in Little Rock Arkansas, but because of the memorial day parades and stuff the Larvae doesn&#8217;t get to see it. Because of it&#8217;s long isolation on Mars, it blames humanity for it&#8217;s troubles, and is intent on causing at least 3 unsolved mysteries and one cold case that is eventually blamed on the victims father on law. It does this by cleverly shooting each subject in the face with a AA torpedo, which is similar to a Photon Torpedo but instead of a Engine driving by fictitious warp plasma it runs on 2 AA batteries. the cold case is inevitably solved in some way or another by the Larvae leaving behind one of the batteries.</p>
<p>About this time, it faces the alter-ego of itself- the Boogers. These are formed when the Larvae accidentally infects a caterpillar that becomes a moth instead of a Butterfly. Due to the increased complications involved in trying to reprogram the moth to become a spaceship (unlike the butterfly, which as I stated would naturally metamorphose into a Interstellar starship if not for the supression gene) the Moth instead has a gene that suppresses it from becoming Liam Gallagher, who, ineffectually, is in fact the single case where the Larvae was unable to change the DNA fast enough to prevent the onset of Gallagralitis.</p>
<p>Those Microconda Larvae which, after reading through a few pages of the code comments on the Caterpillar&#8217;s DNA, determine that they are in fact inside the wrong type of caterpillar, set quickly to work on trying to limit the damage and try ot set them to metamorphize into something more useful. The lucky ones are able to cause the Caterpillar to metamorphize into a large perfect cube of mucus, which have been dubbed &#8220;boogers&#8221; by most 5 year olds who have seen it. The unlucky ones (only one so far) are unable to prevent the inevitable and accidentally cause the caterpillar to metamorph into Liam Gallagher. Thankfully, this has only happened once, and the other few instances were deep in the jungle where he lived his life out as a Howler Monkey. (actually wait, that&#8217;s the same as the one who managed to pass as human&#8230; oh well).</p>
<p>Now, back to the &#8220;boogers&#8221;. Now, As I said, these were the lucky ones. they were able to salvage their situation and still create a interstellar starship with metaphasic shielding, however, the one difference is that they have to wait nearly 60 hours for their outter layer of mucus to try before they enter lightspeed. As it happens, they often encounter the more successful &#8220;butterfly&#8221; marvae when they return from their sabbatical on Mars. The Boogered Moth only has one goal in mind, assimilation of everything else. It wants to integrate everything into it&#8217;s collective. however, unlike the species that I am obviously basing this off, they are a lot smaller. Most of their drones consist of grasshoppers and the occasional Lichen, neither of which are very useful. The &#8220;mucus&#8221; implants are really just a thin coating of mucus that does nothing to enhance their abilities, and there is no need to supress their will because, I mean, their grasshoppers, lichens, and a few stray bits of fluff. Oh, and some wasps. The wasps are probably the easiest to control I would imagine, they have one of the simplest DNA programs. So anyway, they inevitably meet with the vastly superior Butterfly version, and they engage in combat- Usually in and around the Asteroid belt, where the Butterfly Larvae is able to fire far more AA torpedoes then it had originally. The Booger cube uses it&#8217;s established defense tactic of moving lazily to the left, which keeps the Butterfly version on it&#8217;s toes.</p>
<p>The outcome is different everytime.</p>
<p>Well, that&#8217;s not true, there are only 4 possibilities:</p>
<p>1. the Butterfly Larvae wessel destroys the booger cube</p>
<p>2. The Booger cube assimilates the Butterfly larvae ship.</p>
<p>3. Both are destroyed in an ambush by T.I.E fighters</p>
<p>4. Neither one is destroyed, and the butterfly larvae instead moves into a career as a rock musician, while the Booger cube supresses it&#8217;s &#8220;pretty&#8221; gene a little further and becomes a common member on &#8220;The View&#8221;.</p>
<p>Now, the Butterfly larvae wins most of the time, being that the Booger Cubes best defense against the AA torpedoes are mucus torpedoes, which aren&#8217;t very useful. At this point,  regardless of who wins, they celebrate by visiting my Aunt Martha for a bowl of Brown beans. Yes, she is intricately involved in the ecology of a species. I warned her that she was breaking the Prime directive, then I realize that was a completely fictitious law and it was a lot funner to do the opposite anyway. It actually all started when she left the spaghetti leftovers in the fridge for nearly a year. by the time somebody found them they had already grown sentient and had even started their own version of American Idol. (And no, being sentient and watching American Idol don&#8217;t <always> create an oxymoron). Apparently they had been holding frequent referendums between those spaghetti strands that lived touching the sauce (known as saucicans) and those not touching the sauce (whose name isn&#8217;t important, I think they called them John Mayer&#8217;s because of their intrinsic boring quality.) Anyway When my Uncle Ruddiger opened it up, he released the Flying Spaghetti monster, and it has become a ridiculous meme on internet forums and chatrooms ever since. The flying Spaghetti Monster laid eggs and gave birth to the very first Microcondan life forms, which are really only snake-like for a few days.</p>
<p>Anyways, After visiting my aunt Martha, the spend the next 2 years going back in time and just barely making it back, and finally decide that while they don&#8217;t necessarily like Fresca, it&#8217;s not the worst drink in the world, and it&#8217;s certainly good to hae around fort diabetics, who are rather sensitive to their sugar intake. After havingthis epiphany, the StarShip&#8217;s Self-destruct is activated and the Larvae leaves using an escape pod, this escape pod is in fact a long slender organic mass, and is a snake like form as well. At this point it hides itself in Cajun cooking and is ingested. There it lays it&#8217;s eggs and is excreted, and then flushed down the toilet. It makes it&#8217;s way to the sewage treatment plant, where, by careful planning, it manages to sabotage the entire place so that instead of outputting treated sewage it gives out Coca Cola (it only takes a few minor adjustments and a touch of lemon). With it&#8217;s newfound business sense, it now roams across the country converting sewage treatment plants to Coca-Cola bottling knock-off plants. However it is soon discovered that the MicroConda isn&#8217;t actually a human being, which puts a dent in his credibility (namely, the large speech bubble on every can saying &#8220;Yes, I am a human being&#8221;. It slinks off into the shadows, returning only shortly to plan a trip to the Amazon Rainforest where it grew up. At this point, in a twisted set of logic, the Microconda is thinking &#8220;haha, I am so doing this of my own free will, my base instincts would never send me back to the rainforest I grew up, when in fact, that is exactly what is happening. Little does he know it, but the cycle is about to complete.</p>
<p>So, he goes on a tour in the rainforest, pretty much the same one that they filmed that Anaconda film on. Speaking of which, that film was pretty awful. Anyways, once there, it ends up getting in a rather heated debate over toilet paper brands with a local Howler monkey, and soon things start getting personal, both sides start questioning the parentage of the other, the promiscuity of each of their mothers is brought up, as well as their immense weight and various other negative traits. (around this  time it becomes clear that while one is a howler monkey and  the other is a Microconda that a fraction their size, both of their mothers are some sort of diesel or other high octane fuelled locomotive.</p>
<p>After much debate, they both decide to settle their differences by agreeing to disagree, and they both go out for soda. The Microconda, because of his previous epiphany, orders a Fresca. The Howler monkey starts (what else) an intelligent debate about the carcinogenic effects of aspartame, to which the Microconda eloquently replies that there is no real solid evidence either way, and until there is an established, medically sound report that conclusively proves otherwise he wasn&#8217;t going to let nonsense rule over his choices. The howler monkey, at this time, requests that  they have butt sex, which the Microconda of course politely declines, &#8220;It&#8217;s not you, it&#8217;s me, I don&#8217;t have an anus&#8221; he replies. The howler Monkey, heartbroken but quite understanding to the Microconda suggests that he have anal reconstructive surgery in which he can finally achieve his lifelong dream of owning an Anus.</p>
<p>After many years of planning the operation, Dr A. Tear finally decides that it is doable. So, on the following Tuesday, The Microconda finally has an operation to give him an Anus. The Observatorium is packed with onlookers, I was among them- I distinctly recall ordering two hot dogs and a ice cold beer from the fellow selling refreshments, in fact, which I ate and drank while watching the Microconda being torn a new butt-hole, so to speak. Or should I say literally&#8230; I don&#8217;t know.</p>
<p>Unfortunately in the second half of the operation there were complications, namely, Dr. Ass Tear forgot which side of the Microconda was his new butt and which one was his mouth, and started working on the wrong side. This was quickly corrected when I threw my shoe at him from a distance.</p>
<p>After recovering from the surgery for nearly 12 minutes, the Dr. declared it was a complete success. At that point he informed us that he&#8217;d like to keep the Microconda here for at least a week for observation, which seemed fine to me, I mean, I was only sort of related to him through my Aunt martha, and even that was a Dubious connection. The Howler monkey did (what else?) differential equations to pass the time, and tutored his many advanced astrophysics students in the finer points of Einsteins Special theory of relativity, namely the importance of reference frames. Or maybe that the General theory. I don&#8217;t know, I was reading some awful MacCleans magazines from 1994. </p>
<p>After the Microconda recovered, he prompty returned home to his wife, Mrs.Howler monkey, with whom he engaged in frequent butt sex. Unfortunately, during one such episode, the chainsaw they were using became sentient and wrote rude words on the floor. The landlady of the area was not impressed at all and evicted both of them, where they both lived on the street as vagrants for a year before finally starting their own restaurant, &#8220;Howling Snake&#8221; It was mildly successful, at least until that incident where started to murder anybody who tried to pay with a discover card. Once again homeless vagrants in addition to being fugitives from the law, they started to live the homeless life which consisted of mostly not having a home. They made small change by having the Howler monkey do (what else) derived calculus equations on the street for money. unfortunately, their luck quickly got a lot worse. on a trip to the amazon rainforest, The Microconda caught a mild disease known as the &#8220;uncommon cold&#8221;. On his death bed, and dying of an unrelated anal aneurysm, the Microconda promised that wherever they met again, butt sex would surely follow. the Howler monkey did (what else?) spatial IQ puzzles. Shortly after, the Microconda died of Natural causes. As his last request, he wanted to be burned, transformed into a fine paste, spread on toast, and thrown into the rainforest. Nobody knows why- the common belief is that it was the fashion of the time. In any case, certain cells regenerated and formed new MicroConda Virii which continued the cycle once again.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6956635606003080";
/* 728x90, created 4/3/10 */
google_ad_slot = "6964619233";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></always></p>
]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2010/07/the-deadly-microconda-snake/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Mystery of the broken script</title>
		<link>http://bc-programming.com/blogs/2010/04/the-mystery-of-the-broken-script/</link>
		<comments>http://bc-programming.com/blogs/2010/04/the-mystery-of-the-broken-script/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 01:47:09 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[broken]]></category>
		<category><![CDATA[dead skin cells]]></category>
		<category><![CDATA[gumbi]]></category>
		<category><![CDATA[inside out socks]]></category>
		<category><![CDATA[mystery]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[the scary door]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=130</guid>
		<description><![CDATA[For quite some time I&#8217;ve been wrestling with a mysterious issue. You see, I have several COM components. COM, is, to be usable from the various Script languages installed with windows. I encountered this some time ago when creating a small demonstration script file, something along the lines of the following, which simply showed a [...]]]></description>
			<content:encoded><![CDATA[<p>For quite some time I&#8217;ve been wrestling with a mysterious issue.</p>
<p>You see, I have several COM components. COM, is,  to be usable from the various Script languages installed with windows. I encountered this some time ago when creating a small demonstration script file, something along the lines of the following, which simply showed a files size:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">Set</span> BCFS = <span class="kw1">CreateObject</span><span class="br0">&#40;</span><span class="st0">&quot;BCFile.BCFSObject&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">Set</span> ffile = BCFS.<span class="me1">GetFile</span><span class="br0">&#40;</span>WScript.<span class="me1">Arguments</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">WScript.<span class="me1">echo</span> BCFS.<span class="me1">FormatSize</span><span class="br0">&#40;</span>ffile.<span class="me1">Size</span><span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
</ol>
</div>
<p>Very basic.</p>
<p>However, upon running it, I was greeted with the helpful dialog shown in figure 22-1.<br />
<div id="attachment_131" class="wp-caption alignleft" style="width: 500px"><img src="http://bc-programming.com/blogs/wp-content/uploads/2010/04/helpful.png" alt="VBScript ActiveX Error" title="helpful" width="490" height="227" class="size-full wp-image-131" /><p class="wp-caption-text">Fig 22-1: VBScript Error</p></div></p>
<p>For some reason or another, the ActiveX Object simply couldn&#8217;t be created (I gathered this after many long hours of research). My first &#8220;retry&#8221; was simple- I at first simply assumed that I had to run as administrator, so I started a command prompt as administrator, and ran it again.</p>
<p>Same error.</p>
<p>This was getting to be annoying. I tried a equal script in JScript/ECMAScript or whatever the hell it&#8217;s called these days:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">BCFS = <span class="kw1">new</span> ActiveXObject<span class="br0">&#40;</span><span class="st0">&quot;BCFile.BCFSObject&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">ffile = BCFS.<span class="me1">GetFile</span><span class="br0">&#40;</span>WScript.<span class="me1">Arguments</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">WScript.<span class="me1">echo</span><span class="br0">&#40;</span>BCFS.<span class="me1">FormatSize</span><span class="br0">&#40;</span>ffile.<span class="me1">Size</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
</ol>
</div>
<p>It failed as well. so it wasn&#8217;t because of something I was doing wrong in the script. I then tried an alternative; I created a Visual Basic Project, and ran similar code.</p>
<p>It was able to create and use the object with absolutely no difficulty.</p>
<p>I was beginning to find this whole exercise at least as intriguing as it was frustrating. I decided to explore what happened with other operating Systems with VMWare. The script ran fine in Windows 2000 and Windows XP (assuming of course I had installed BCSearch or otherwise had BCFile.dll properly installed). However, it continued to fail. I went into a test frenzy. It failed on Windows 7 on both my laptop and desktop, worked in all my VMWare installations (including Vista) I was stymied.</p>
<p>Then, I ran it on two copies of Windows XP I had on my laptop. Windows XP Pro worked fine. Windows XP x64 did not.</p>
<p>So it was an architecture issue, I surmised. Going on that, I came to the realization that a 64-bit executable cannot instantiate a 32-bit COM object, at least, not an In-Process (DLL) COM object. This was likely the source of the error. I Ran a simple script with a msgbox() that would keep the Script runner running, and then opened Process Explorer.</p>
<p>Not surprisingly, the WScript.exe Process was 64-bit, this was the cause of my problems. the fix? Run the WScript or CScript in %systemroot%\syswow64\ instead. I did so, and the script ran without incident.</p>
]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2010/04/the-mystery-of-the-broken-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>VB6, VB.NET, RealBasic&#8230; or, &#8220;why the hell can&#8217;t we just get along?&#8221;</title>
		<link>http://bc-programming.com/blogs/2010/03/vb6-vb-net-realbasic-or-why-the-hell-cant-we-just-get-along/</link>
		<comments>http://bc-programming.com/blogs/2010/03/vb6-vb-net-realbasic-or-why-the-hell-cant-we-just-get-along/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 06:05:57 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=120</guid>
		<description><![CDATA[I&#8217;ve been reading a blog- specifically, Addressof. I could ramble on for hours about various things he has said- bit it would be just nitpicks about things. Anyway, this post, or more precisely, some of the comments, attracted my attention. There is no argument that when MS completely dumped Visual Basic 6 in favour of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading a blog- specifically, <a href="http://addressof.com">Addressof</a>.</p>
<p>I could ramble on for hours about various things he has said- bit it would be just nitpicks about things. Anyway, <a href="http://addressof.com/blog/archive/2005/03/11/1430.aspx">this</a> post, or more precisely, some of the comments, attracted my attention.<br />
<span id="more-120"></span><br />
There is no argument that when MS completely dumped Visual Basic 6 in favour of the .NET platform it was a paradigm shift. And VB.NET, C#, F#, and some of the other language are great languages. I think the entire point is that Visual Basic, in 1998, was a well established pinnacle for RAD; when you thought Rapid Application Development, you thought of Visual Basic. It had, as noted elsewhere in the post, billions of lines of production code, some of which was possibly compiled and the source lost but still in use. </p>
<p>The entire argument is that if they did it once, it becomes easier for MS to do it again. Microsoft has been famous and infamous for it&#8217;s attention to backward compatibility; Visual Basic versions were no exception; until .NET, when support was completely cut off.</p>
<p>The entire point is simply upgradability. It is NOT easy to upgrade any non-trivial application to .NET. it simply isn&#8217;t going to happen. For most projects it would be a lot easier to just rewrite it. Take, for Example, BCScript. The parser would be rather simple to write in VB.NET/C# and in fact I&#8217;ve been meaning to do so for some time, but there is no way in hell I&#8217;m going to be able to import &#8220;BASeParserXP.vbp&#8221; into .NET and have everything hunky dory. There are a LOT of COM specific calls that use reflection (well, typelib information) and COM invocations. This is why a rewrite would be a lot better in this instance: since the basic shift is from COM to .NET. Sure, some dinky little address tracker or something won&#8217;t need any extra work, but consider that many businesses are still relying on Visual Basic 6 components to keep their business alive. If some version of Windows suddenly removed that support, they simply will not upgrade. In fact, this is actually a reality- many businesses are not upgrading to the 64-bit architecture because 16-bit applications, such as those written in VB4-16 and earlier, don&#8217;t work.</p>
<p>Yes, perhaps they can be upgraded. But consider that many of these companies are not a software company. Many of them are things like construction firms and law offices and so forth. They really don&#8217;t care that .NET makes application development easier or, that  there are so and so classes available in the Framework. All they care about is that their order tracking system  <works>. Additionally, considering that many such companies contracted the development of said software from a third party (and since they do not specialize in software they probably don&#8217;t even have the source code), there is no direct upgrade path to .NET, even if it was as simple as opening the project in .NET and recompiling. </p>
<p>One of the more interesting comments (which deservingly, received a good amount of flak) was this one:</p>
<div style="background-color:#C0C0C0;">
First of all, VB is barely a programming langauge. Only in .NET did it come close to catching up with C++ in terms of ability. It&#8217;s still not there, though. But now VB compiles into p-code (C# does, too&#8230;they now run on the CLR), leaving you feeling like you might as well write a whole program in Perl. It&#8217;s about time Microsoft gave up on that language, it&#8217;s only making real programmers soft minded and lazy. I&#8217;m just waiting for the day when they get rid of VB.NET. Also, just look at what VB.NET is, you&#8217;re creating a COM object that is a program. Simply, all that I-this, I-that is COM stuff&#8230;so COM is not dead, only hidden. Only the mind of a hard-core VB &#8220;programmer&#8221; is dead. cha, cha, cha, OLE!</p>
<p>And as for the OOP paradigm in VB&#8230;Like Microsoft says, VB uses polymorphism through COM objects. i.e., it&#8217;s not real polymorphism, but if I squint my eyes hard enough it looks like Polymorphism.
</p></div>
<p>Now, this poster is talking out their ass, pure and simple, because their entire argument is shit. (haha, uncensored blog posts are fun)</p>
<p>Let us examine each point in detail. </p>
<div style="background-color:#C0C0C0;">
First of all, VB is barely a programming langauge.
</div>
<p>Well, damn. That&#8217;s the most powerful argument ever. gotta love how it get&#8217;s backed up with facts&#8230; Oh wait, it didn&#8217;t. This is yet another C/C++ programmer who has had it drilled in his head that any language without curly braces is shitty. well all you need is two braces and an o to see what they are being. {o}. The main problem with this concept is that if it was barely a programming language I highly doubt it would be turing complete. I think the more accurate phrasing would be &#8220;First of all, I don&#8217;t consider VB a programming language because I&#8217;m a language agnostic who doesn&#8217;t understand it and followed the paradigm that since I am super smart anything I don&#8217;t understand is neither worth my time nor worth anybody else&#8217;s time. Additionally I enjoy copious amounts of butt sex with my like-minded C developers&#8221;, which, aside from possibly the reference to sodomy, is rather accurate. C/C++ developers have a sort of superiority complex when it comes to what they deem &#8220;lesser&#8221; languages. The obvious root cause is simply jealousy, after all, in pure C a Simple windows application can take several pages of code. and MFC doesn&#8217;t exactly make C++ fully friendly on that front, either. Visual Basic does. The transliteration as far as these superior C/C++ beings are concerned is somehow that the language is inferior. In a similar vein, I could simply say that VB is better merely because it posesses an exponentiation operator. cheap shot? Yes. but it flows in the same vein. See, it&#8217;s not about what is and isn&#8217;t a programming language, it&#8217;s about what get&#8217;s the job done faster, and when you understand one language better then another it&#8217;s no surprise that jobs done with it get done faster.</p>
<p>The sad thing is that C# developers share the same superiority complex towards VB.NET. myself included, actually. And I mean, they are running on the same framework- they have nearly the same feature sets and capabilities. And yet you still find C# advocates whose entire argument consists of the spelling of a keyword or other baseless argument.</p>
<div style="background-color:#C0C0C0;">
Only in .NET did it come close to catching up with C++ in terms of ability.
</div>
<p>Yet another well researched opinion. I say that sarcastically. Unless of course he was able to research this subject by reading the walls of his large intestine, I highly doubt this commenter was able to pull his head out of his ass long enough to even understand what he was talking about.</p>
<p>Anything you can do in C/C++ you can do in VB6. is it easy? Not always. But considering that nearly anything in C++ is a struggle against a set of warnings and compiler errors anyway I&#8217;ll take VB6&#8242;s &#8220;make 90% of the task simple&#8221; approach anyday. A Prime example is BCSearch. If one didn&#8217;t know better, it&#8217;s rather easy to think it was written in VB.NET, C#, or C++. It simply doesn&#8217;t meet the typical &#8220;expectations&#8221; of a Visual Basic 6 program. It&#8217;s rather easy to create an application in any language, perfecting that application and it&#8217;s appearance is not, regardless of your language. The fact that VB6 doesn&#8217;t make on-par UI design easy with such introductions and Luna and Aero themes is not a fault of Visual Basic but rather one of the fact it was written in 1998; besides, such limitations are easily overcome using simple manifests. The only true limitation I have yet to surmount is the fact that I cannot seem to get any non-trivial application to run properly without being run as an administrator. XP/Vista style icons for the application icon are not possible using the built in tools of Visual Basic 6 (which does not understand 32-bit Alpha icons) but it&#8217;s a simple task to create a resource file using RC that includes the desired application icon. Same ease of use goes for the inclusion of manifest files and the like for support of XP and Vista themes. The fact that books like  HardCore Visual Basic and sites like vbaccelerator.com exist are pretty much indications that it&#8217;s not just a programming language, but like any other programming language, it&#8217;s a culture. This is in fact why the shift to .NET can be difficult- it&#8217;s a culture shock. Like suddenly noticing that your Asian or don&#8217;t have toes.</p>
<div style="background-color:#C0C0C0;">
But now VB compiles into p-code (C# does, too&#8230;they now run on the CLR), leaving you feeling like you might as well write a whole program in Perl.
</div>
<p>yet another unresearched opinion stated as fact.</p>
<p>&#8220;P-Code&#8221; was originally usable in some versions of Microsoft C. the motivations for it I am unsure of, but it automatically included a PCode interpreter in your application.</p>
<p>Visual Basic versions 1 through 4 were always compiled to a sort of P-code; basically, very low level bytecode that was interpreted by a VM. Which I believe was contained in the VB runtime.</p>
<p>the .NET framework, or more precisely, the CLR, executes something called &#8220;IDL&#8221;- Intermediate Language. Now, the important thing to realize is that IDL is <not> P-Code. It includes features such as JIT; and, in fact, the IDL that you compile a .NET assembly to will be run as machine code on the target machine that is what the CLR does. it compiles it on the fly to native code, same as the JVM.</p>
<p>Additionally, it&#8217;s important to note that a &#8220;bytecode interpreter&#8221; is many times faster then a script interpreter; perl may have it&#8217;s own optimizations inside but either way it&#8217;s still going to need to parse your pl file and create the appropriate structures. compiling to IDL is sort of like building an expression tree out of an expression. You don&#8217;t necessarily know what it was made from but you can glean what it is supposed to do.</p>
<div style="background-color:#C0C0C0;">
It&#8217;s about time Microsoft gave up on that language, it&#8217;s only making real programmers soft minded and lazy.
</div>
<p>Perhaps. he provides no evidence of this. They do however provide a copious amount of evidence for the case of &#8220;C/C++ can make real programmer elitist assholes&#8221;</p>
<div style="background-color:#C0C0C0;">
Also, just look at what VB.NET is, you&#8217;re creating a COM object that is a program. Simply, all that I-this, I-that is COM stuff&#8230;so COM is not dead, only hidden. Only the mind of a hard-core VB &#8220;programmer&#8221; is dead. cha, cha, cha, OLE!
</div>
<p>This particular expert really exemplifies how deeply rooted this poor posters head has gotten in their ass. They evidently do not even understand what COM is, much less how .NET, while allowing you to create .NET assemblies accessible via COM, does not, by default ,create any COM objects at all. I believe the intent is perveyed by removing &#8220;COM&#8221; from it. COM is not used here. .NET is a different framework with different goals. just because &#8220;i&#8221; is used as prefix for interfaces doesn&#8217;t suddenly make something based on COM. this is a rather ridiculous notion, since it implies that java is also based on COM. This entire paragraph says &#8220;I don&#8217;t understand objects and class-based programming. all objects are COM to me. long live gets()!&#8221;</p>
<div style="background-color:#C0C0C0;">
And as for the OOP paradigm in VB&#8230;Like Microsoft says, VB uses polymorphism through COM objects. i.e., it&#8217;s not real polymorphism, but if I squint my eyes hard enough it looks like Polymorphism.
</div>
<p>yet another example if retarded people saying retarded things. I&#8217;m not even sure which VB we&#8217;re talking about. He seems to think COM is OOP, but it isn&#8217;t, except evidently deeply up his ass where his head has come to rest. Polymorphism is treating an object as if it is another object. you can treat a TextBox, for example, the same as you would any Control. Just as you can treat any object as if it were an instance of an interface that it implements. That is polymorphism. Additionally, if <i>I</i> squint really really really hard, I see a small brained lunatic with a inferior understanding of basic programming concepts trying to play in the big boy sandbox, and all he does is piss all over it. Bastard.</p>
<p>The rest of the comments really go overboard. Mostly people claiming to have the inside track to knowledge, kind of like Fritz Zwicky, the first person to conceive of the concept of a neutron star. Which later was proven to actually exist.</p>
<p>Basically, their inside knowledge, as I&#8217;ve stated several times here, must be coming from the walls of their ass.</p>
<p>Anyways, I&#8217;m rather full of energy, so let&#8217;s say I respond to his follow up post!</p>
<div "background-color:#C0C0C0;">
Yes, I think VB is barely a programming language. If it doesn&#8217;t compile directly into bona-fide instructions, then I don&#8217;t consider it a legit programming language. I would prefer to call them scripting languages, because something else is _always_ needed to run them. When you compile a VB program, you&#8217;re really saying &#8220;Hey you C/C++ guy, go and do this for me.&#8221; And it&#8217;s that simple. So, yeah, I&#8217;m a bit of a purist in that sense. But also keep in mind that VB is considered a high level language, whereas C/C++ is considered a low level language, and of course Assembler is as low as it gets&#8230;which is one step below C/C++.
</div>
<p>This is seriously the most ridiculous head-up-the-ass thing I&#8217;ve ever heard. &#8220;it&#8217;s not a real language because it doesn&#8217;t compile to native code&#8221; is completely and utterly the most ridiculous thing I&#8217;ve ever heard. the way a program is compiled doesn&#8217;t define the language. I&#8217;d suggest he give his head a shake but considering it&#8217;s so deep up his ass he might get some sort of sick sodomite pleasure from it. (yes, I do need to keep making references to that)</p>
<div "background-color:#C0C0C0;">
I&#8217;m going to start something now, because perspective seems to be lost:<br />
You can think of VB this way: The real programmers (not necessairly C/C++ people) were sick of being bothered by the half-wit wanna-be-programmers always having code that didn&#8217;t do what they wanted it to. So, the real programmers created a rubber room with a sun painted on the ceiling for the half-wits to play in. Now the real programmers just pat the half-wits on the head and say, &#8220;go play now, Timmy.&#8221; And the half-wit says, &#8220;Hey, I can see the sun!&#8221; The only problem is, some good programmers have joined the VB bandwagon. Well, in short, VB has no memory management, no pointers. It&#8217;s a safe room, and really, where better to do testing?
</div>
<p>And the good programmers use pointers and direct memory copies, while taking advantage of not having to do those things otherwise. In either case, seeing the sun is better then <insert head up ass joke>. There are other problems with that paragraph but this poor soul is a lost cause. (I mean seriously, *cue deep imitation voice* &#8220;It&#8217;s not a language if it doesn&#8217;t compile to machine code&#8221;, fucking hopeless retard. He demonstrates his ignorance right here:</p>
<div "background-color:#C0C0C0;">It&#8217;s not called Visual BASIC for nothing. That&#8217;s why IBM chose the name BASIC, it implies simple, easy. VB is a derivative of BASIC, which was never meant to be a real commercially used language. So sign the anti-petition? Hell, yes. And I&#8217;ll sign any petition that will aide in getting rid of VB as viable language choice. The only use for VB is VBA for people like Analysts, Accountants, Secretaries, et cetera who need to do the same menial tasks over and over again in Excel.
</div>
<p>WHAT A FUCKING MORON.</p>
<p>If you&#8217;re going to spout &#8220;facts&#8221; at least make then accurate. If you&#8217;re going to badmouth a language based on it&#8217;s roots, at least get the fucking roots right you brain-dead possum fucking shrew faced turkey necked weasel toed koala bear fucker! BASIC was NOT CREATED BY IBM. it was invented at DartMouth college by Kemeny and Kurtz. &#8220;to provide computer access to non-science students.&#8221; which may seem to prove the point of this particular platypus-dicked Polar bear diaper fetishist, but consider that C/C++ was created for same damn reason, since ASM was simply a huge pain in the ass.</p>
<p>According to Wikipedia (and don&#8217;t worry, these 8 rules are backed up by my ancient college BASIC textbook)</p>
<p>BASIC was designed with 8 simple rules:</p>
<p>The eight design principles of BASIC were:</p>
<p>   1. Be easy for beginners to use.<br />
   2. Be a general-purpose programming language.<br />
   3. Allow advanced features to be added for experts (while keeping the language simple for beginners).<br />
   4. Be interactive.<br />
   5. Provide clear and friendly error messages.<br />
   6. Respond quickly for small programs.<br />
   7. Not to require an understanding of computer hardware.<br />
   8. Shield the user from the operating system.</p>
<p>Apparently, what this particular Lemming Snuffing incestuous beastiality lover has a problem with is rule 3: apparently, it shouldn&#8217;t be allowed to both have advanced features AND keep the language simple for beginners. no! everything must be complicated to all shit, like trying to figure out how he&#8217;s going to organize his huge animal orgies, making sure every Dongle has a port to plug into, so to speak. like a version of tetris, but far more likely to cause bouts of vomiting. There is absolutely no problem with any of these steps! (except perhaps number 8, but because of number 3, it should be rather easy to work around by definition).</p>
<p>It&#8217;s important for Chinchilla loving Carnal Ostrich visitors such as them to understand how the language evolved to what it is today rather then criticizing what the language is now based on what it was.</p>
<p>Almost every single interpreter for BASIC ever made was considered by BASIC&#8217;s creators as a &#8220;Street BASIC&#8221;- which means they don&#8217;t even consider it worthy of the name BASIC. the very fact that they posessed a data type made them shudder. It went against the very mantra of BASIC.</p>
<p>But, BASIC changed. it evolved. the BASIC of 1984 was already so far and way from the original design of Kemeny and Kurtz that it shouldn&#8217;t have even been called BASIC at all. And yet 16 years later there are people using the original definition and design goals of BASIC, something that has been dead and buried for years and forgotten, as some sort of argument against  what VB.NET is today? What&#8217;s next? Are we going to start criticizing java because it was original designed for appliances? Get real. Designs change. so too must minds.</p>
<p></insert></not></works></p>
]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2010/03/vb6-vb-net-realbasic-or-why-the-hell-cant-we-just-get-along/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How 2012 type crap starts</title>
		<link>http://bc-programming.com/blogs/2010/03/how-2012-type-crap-starts/</link>
		<comments>http://bc-programming.com/blogs/2010/03/how-2012-type-crap-starts/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 19:08:17 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=90</guid>
		<description><![CDATA[for the last little while, people with fewer brain cells then a Pygmy chimpanzee&#8217;s middle finger have been going on and on about how the &#8220;world will end in 2012&#8243;. Well, I have a little story for you all- It&#8217;s set in the year 2098. Archeologist (or, as they will be called then, digger men) [...]]]></description>
			<content:encoded><![CDATA[<p>for the last little while, people with fewer brain cells then a Pygmy chimpanzee&#8217;s middle finger have been going on and on about how the &#8220;world will end in 2012&#8243;. Well, I have a little story for you all-</p>
<p>It&#8217;s set in the year 2098.</p>
<p>Archeologist (or, as they will be called then, digger men) will be using their dirt shovers (what we now call a shovel) and come upon a beige box.</p>
<p><a href="http://apcmag.com/system/files/images/old-pc-canberra.article-width.jpg"><img class="alignnone" src="http://apcmag.com/system/files/images/old-pc-canberra.article-width.jpg" alt="" width="253" height="215" /></a></p>
<p>Experts will be baffled! They released the following information on what they believe the object to be and what it was for.</p>
<p>Professor Jeffson has a theory- he believes that the object was used for storing, and retrieving personal data. the logo &#8220;IBM&#8221; was an insignia of a long dead religion that dedicated themselves to getting down to business with machines.</p>
<p>Professor Ytterby, on the other hand, has a different theory- he concludes that the device was used for predicting the lunar cycles of the moon, and by using the alphabetic input device, it could predict when people would die. Later, and to the amazement and grief of a large crowd, he powered on the machine and entered the following data at the prompt:<br />
<font face="consolas,courier New"><br />
Current Date is Tue 01-01-80<br />
Enter New Date: (mm-dd-yy):<b>01-01-2100</b><br />
</font></p>
<p>What he didn&#8217;t realize was that what he would reveal with one keystroke was more then any man should ever know.</p>
<p><font face="consolas,courier New"><br />
Current Date is Tue 01-01-80<br />
Enter New Date: (mm-dd-yy):<b>01-01-2100</b></p>
<p>Invalid Date<br />
Enter New Date: (mm-dd-yy):<br />
</font></p>
<p>Invalid date?</p>
<p>The professor came to the only logical conclusion- the universe was going to end on the year 2100. The ancient Americans knew of this day, using their advanced vision boxes called &#8220;televisions&#8221; they were able to see into other people lives, and steal their thoughts. It was also believed that they referred to spoons as &#8220;face trowels&#8221; and would often purposely do something and loudly exclaim &#8220;did I DO THAT?&#8221; in a nasally whine that would make Cyndi Lauper blush.</p>
<p>This news spread like wildfire (literally, in fact, as the entire backbone of the internet will be based on the spread of wildfires) Threads such as the following:</p>
<hr color="black"/>
Posted by <b><u><font color="blue">NikolaBreastla</font></u></b>(Newbie with 13 posts) at 3:04PM On Wednesday, November 26th 2098 </p>
<hr color="#D0D0D0"/>
No Way<br />
I Don&#8217;t Believe It</p>
<hr color="#D0D0D0"/>
<i>NikolaBreastla: the famous Russian scientists we&#8217;d all know had he run a brothel</i></p>
<hr color="black"/>
Posted by <b><u><font color="blue">BoObRaT</font></u></b>(Member with 140 posts) at 4:50PM in Wednesday, November 26th, 2098</p>
<hr color="#D0D0D0"/>
I HAVE PROOF!</p>
<p>THEY ALSO FOUND A WATCH AT A MORMON BURIAL GROUND, IT WAS STOPPED ON 7/28/1973 AT EXACTLY 11:03:55 PM! YOU DUMS KNOW WHAT THIS MEANS?</p>
<hr color="#D0D0D0"/>
<i>&#8220;If you get to second base and tell, your a boobrat&#8221; &#8211; Frank Sinatra IV</i></p>
<hr color="black"/>
Posted by <b><u><font color="blue">BASeChomper II</font></u></b>(member with 400 posts) at 8:04PM On Wednesday, November 26th 2098 </p>
<hr color="#D0D0D0"/>
<div style="background:#C0C0C0;border=1px black;">
<font size="2"><b>Quote From:<font color="blue">BoObRaT on at 4:50PM in Wednesday, November 26th, 2098</font></b><br />
<i>THEY ALSO FOUND A WATCH AT A MORMON BURIAL GROUND, IT WAS STOPPED ON 7/28/1973 AT EXACTLY 11:03:55 PM! YOU DUMS KNOW WHAT THIS MEANS?</i><br />
</font></div>
<p>First: release caps lock. I&#8217;m sick of telling you over and over and over again to type normally. It doesn&#8217;t make you look smarter. Remember that thread where you argued that the shape was easier to read and I shot you down with 5 case studies by reputable organizations? yeah, that was sort of a hint that you don&#8217;t know what your talking about.</p>
<p>Any way- I think that could mean:</p>
<p>That they had really bad watches?</p>
<p>There really were no golden plates?</p>
<p>They were grave robbers? </p>
<p>Come on! Tell us.</p>
<hr color="#D0D0D0"/>
<i>My Grandfather was lacktoes intolerant. He couldn&#8217;t stand people with no toes.</i></p>
<hr color="black"/>
Posted by <b><u><font color="blue">BoObRaT</font></u></b>(Member with 140 posts) at 9:12PM in Wednesday, November 26th, 2098</p>
<hr color="#D0D0D0"/>
Sorry about the caps BC, I know, I remember that thread. I still think they&#8217;re easier to read though, regardless of what anybody says.</p>
<p>The watch stopped at the exact time equivalent to 01/01/2100 divided by the constant <i>e</i> Couldn&#8217;t it be more obvious?</p>
<hr color="#D0D0D0"/>
<i>&#8220;If you get to second base and tell, your a boobrat&#8221; &#8211; Frank Sinatra IV</i></p>
<hr color="black"/>
Posted by <b><u><font color="blue">BASeChomper II</font></u></b>(member with 400 posts) at 9:14PM On Wednesday, November 26th 2098 </p>
<hr color="#D0D0D0"/>
<div style="background:#C0C0C0;border=1px black;">
<font size="2"><b>Quote From:<font color="blue">BoObRaT at 9:12PM in Wednesday, November 26th, 2098</font></b><br />
The watch stopped at the exact time equivalent to 01/01/2100 divided by the constant <i>e</i> Couldn&#8217;t it be more obvious?<br />
</font></div>
<p>It could have been more obvious. You could have said that to begin with instead of trying to build up suspense. And you generally use caps to break the suspense, not build up to it. And I don&#8217;t care what you think of caps, it&#8217;s called &#8220;proper grammar&#8221; dumbass.</p>
<p>Anyway, the fact that the time stopped at that particular point it pretty circumstantial. That would be like saying that my great great aunt martha had 5 toes and ate meatloaf every Tuesday so she must have been a good square dancer. I&#8217;ll have you know she became a good square dancer through dogged training and a strong resolve, not simply by having the standard number of toes and eating meatloaf made from an unspecified animal.</p>
<hr color="#D0D0D0"/>
<i>My Grandfather was lacktoes intolerant. He couldn&#8217;t stand people with no toes.</i></p>
<hr color="black"/>
Posted by <b><u><font color="blue">NikolaBreastla</font></u></b>(Newbie with 13 posts) at 11:04PM On Wednesday, November 26th 2098 </p>
<hr color="#D0D0D0"/>
Why the hell is it in all of my posts it&#8217;s ended up with that BC guy and the boobrat guy arguing about capital letters? </p>
<hr color="#D0D0D0"/>
<i>NikolaBreastla: the famous Russian scientists we&#8217;d all know had he run a brothel</i></p>
<hr color="black"/>
Posted by <b><u><font color="blue">VinylSiding</font></u></b>(Moderator with 1305 posts) at 1:04AM On Thursday, November 27th 2098 </p>
<hr color="#D0D0D0"/>
<div style="background:#C0C0C0;border=1px black;">
<font size="2"><b>Quote From:<font color="blue">NikolaBreastla</font> on 11:04PM On Wednesday, November 26th 2098<br />
</b>Why the hell is it in all of my posts it&#8217;s ended up with that BC guy and the boobrat guy arguing about capital letters?<br />
</font></div>
<p>It&#8217;s a corrolary to Godwins law: all threads involving BC and BOobrat will devolve into a pointless flamewar about either use of capitalization or wether a mouse with a large boob is in fact a rat.</p>
<hr color="black"/>
<p>And trust me- It just goes downhill from there.</p>
<p>Anyway, in a mildly serious manner- I find it even more disturbing that devout Christians are even giving this a second thought. They were rather barbaric by modern standards, sacrificed virgins and car salesman, believed in multiple &#8220;spirits&#8221; (gods) and yet, despite their evident paganism and completely lack of &#8220;knowing the true path&#8221; (as a missionary might put it), most of them seem to think of it as somehow credible. Although, I suppose it&#8217;s perfectly possible they created a giant telescope and were able to see a large comet heading straight towards us, possibly by using a number of butler monkeys to love about the various mechanical bits they had&#8230;. actually, wait a moment, I don&#8217;t even think the mayans had the wheel.</p>
<p>This is almost understandable for catholics, since their church really is just a government- like the many other times the apocalypse was predicted and they told all their loyal followers &#8220;well, you may as well donate all your worldly possessions to the church&#8221; and so many people did&#8230; and then after when nothing happened, people would go back &#8220;oh, hey, err&#8230; I sorta need that stuff I donated back&#8221;, and the church would inevitably make up some excuse involving poncho size measurements. Actually, that gives me an idea. People! this is a great opportunity! Instead of responding to such claims that &#8220;the world is going to end&#8221;! get them to give you all their stuff.  </p>
<p>Yes people, that is the new low we&#8217;ve all stooped to. Now we have people believing prophecies from an &#8220;advanced&#8221; civilization that couldn&#8217;t even figure out the wheel. I imagine it follows that they didn&#8217;t have gears either&#8230; And you can only throw so many butler monkeys at a problem before the shit hits the fan&#8230; pun not intended, of course, being that a fan would require understanding of at least some sort of rotary motion. Besides, most of their butler monkeys were probably building their goofy pyramids that they build for sacrifices as well as for housing their valuable collection of first-edition pokemon cards. It&#8217;s another little known fact that the reason they were rather frightened of the Spanish was not because of their muskets, but rather because of the shape of their ammo. you see, as I mentioned the wheel, and therefore any elliptical shape, was somewhat of an enigma to them. this is quit clear in that all their sculptures give faces square features (or maybe they really had square heads, I don&#8217;t know). for a while they fought bravely, but then they managed to capture a spanish car salesman (who was trying to sell them a Jetta). When investigating his sales-musket, they discovered, to their horror- spherical ammunition. Their best scientists immediately went to work by testing them. they discovered that they rolled easily, and therefore must originate from the dimension of the doomed (a dimension which was later featured in Quake). They responded in force by sacrificing a low financing rate for their Jetta in exchange for some information from the salesman, which proofed fruitless since nobody&#8217;s universal translator was working at the time.</p>
]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2010/03/how-2012-type-crap-starts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Metrics: they simply don&#8217;t work.</title>
		<link>http://bc-programming.com/blogs/2010/02/metrics-they-simply-dont-work/</link>
		<comments>http://bc-programming.com/blogs/2010/02/metrics-they-simply-dont-work/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 03:29:05 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Theory]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=84</guid>
		<description><![CDATA[Companies and businesses want to prosper. At the core, being a successful business means that you make a sizable revenue; But, when those start to falter, how do businesses determine the cause? They generally measure something; for a programming firm, this may be lines of code written. For a restaurant, perhaps the time it takes [...]]]></description>
			<content:encoded><![CDATA[<p>Companies and businesses want to prosper. At the core, being a successful business means that you make a sizable revenue; But, when those start to falter, how do businesses determine the cause? They generally measure something; for a programming firm, this may be lines of code written. For a restaurant, perhaps the time it takes for a customer to be seated, and so forth. And on the surface, it makes sense.</p>
<p>The problem is, it only makes sense,<em>in theory</em>. Why? because both methods are trying to tack a quantitative statement onto something that cannot be measured in this way; additionally, they forget the human factor.</p>
<p>Let&#8217;s look at a hypothetical situation; Programmer Joe. Programmer Joe has worked at a Software startup since it&#8217;s early days, and enjoys his job. However, one day, the CEO calls them all into the office to discuss declining revenue. Realistically, the revenue is declining because a competitor has just released a product that directly competes with the startup&#8217;s flagship software package. However,  management believes that the loose leash they&#8217;ve been keeping the programmers on is to blame; so one of the idea men determines that they should implement a management technique known as metrics. In this case- they start with something basic; each programmer&#8217;s performance will be judged directly correspondent to the number of lines of code they write.</p>
<p>Programmer Joe continues his work as normal; he notices some of his co-workers checking in code that re-rolls standard library routines, and cuts out excess code like this. One day he&#8217;s called into the Project Manager&#8217;s office.</p>
<p>&#8220;Joe&#8230; I don&#8217;t know quite how to explain this- maybe you can. Somehow, you&#8217;ve managed to accumulate a [i]negative[/i] lines per day metric&#8230; any idea how that is possible?&#8221;</p>
<p>&#8220;Well, I&#8217;ve noticed a lot of redundant code being checked in, and trimmed it down. the code still works the same way- it&#8217;s just faster; also, I&#8217;ve managed to fix half the bugs on the list just by doing that.&#8221;</p>
<p>The Project Manager may, in this case, take this particular information to the higher levels. they decide that the metric is flawed- what they need ot measure is lines of code written minus the number of bugs introduced.</p>
<p>A feature request arrives from a client near the end of the day, at 4:30PM. the Project Manager asks if Joe can look over the request and if he can maybe stay late to try to get some of those features implemented. So Joe spends the next three hours creating a prototype for the new feature and once he has the main functionality down he checks the code in and goes home. The next day, Joe continues his work on this new feature. However, he is once again called into the Project Manager&#8217;s office.</p>
<p>The Project manager hands Joe a large stack of papers.</p>
<p>&#8220;you know what those are, Joe?&#8221;</p>
<p>&#8220;No&#8230;&#8221;</p>
<p>&#8220;Those are the bug reports filed on code you&#8217;ve checked in recently.&#8221;</p>
<p>&#8220;All the code I&#8217;ve been working on recently has been a prototype&#8230; I haven&#8217;t yet gotten it fully integrated into the rest of the system.&#8221;</p>
<p>&#8230;</p>
<p>I think you can see where I was going there. basically, the fact is that havign a measuring metric that measures small fiobles in the entire process is doomed to cause hiccups within that process and even bring business to a standstill. In this case, rather then worry about the number of lines of code written or the number of bugs introduced, it might be better to focus on fixing the bugs and adding features; the number of lines of code in a project does not directly correspond to the quality of that project as a whole, and in some cases can even do so inversely.</p>
<p>In a strange coincidence, a local Coffee shop that Programmer Joe visits on his way to work had noticably changed. When Joe used to go though their drive thru to grab his morning coffee and a box of donuts for his colleagues, the staff were friendly and often asked him how things were going. Recently, however, Joe has felt like a piece of scrap metal on an assembly line. Once he got to the pay window, he would often hear audible grumbles of discontent as he simply reached into his pocket for his wallet. His donuts have often been obviously simply thrown in the box with little care, too. Joe couldn&#8217;t understand it, since these were the very same people that would serve him before. Eventually, Joe decided to go elsewhere for his morning coffee.</p>
<p>The previous paragraph is not an entire fabrication; in fact, I work at a location that does just this. They time every single drive thru customer&#8217;s time at the window, and it&#8217;s treated as the single most important measurement of performance in the entire store. I&#8217;d even go so far as to say it seems to be used to reflect directly customer satisfaction. However, this simply is not the case. The franchise, in particular, places a recommended limit of 42 seconds for waiting at the window. a reasonable time frame, depending on the volume of customers. However, at my location it has now been decreed that we shall not take longer then 30 seconds or, from what I hear of others, they will be verbally &#8220;abused&#8221; about it.</p>
<p>In any case, a little backstory is probably in order. Lately it would appear that revenue has been dwindling; there are far fewer customers then I remember coming in, at all times of the day. Additionally, various seemingly pedantic rules have been places on our release of such seemingly trite things as butters and napkins. It&#8217;s fair to assume in this case that they obviously want to bring business back up again- and that is certainly something anybody in that position would try to do.</p>
<p>However, with that said, they are going about it wrong. In the Retail and Customer Service industry- where almost all revenue is coming from consumers who purchase your product by coming to your establishment, the all-time, 100% most important thing for business is customer satisfaction. No exceptions. Interestingly enough, since this has started, I&#8217;ve gotten dozens of complaints from Customers who visit regularly about the shoddy way they were treated while going through the drive thru at some other time during the day. This certainly is not the fault of the workers at the time; since, as I said, they are essentially being &#8220;forced&#8221; to try to reduce times to &lt;30 seconds. But when you get customers, the main source of revenue for the store, complaining about something that is the result of a change to the store policy that was introduced to try to increase revenue it is pretty solid evidence that the technique has failed miserably.</p>
<p>The problem here is not that those in charge know, as well as anybody else, that customer satisfaction is the single most important thing to the stores success, but rather in that they have tried to assign a single metric to measure this particular quality. And they do not correspond. I certainly won&#8217;t argue that customers prefer fast service— it certainly is on their list of hopes when they enter a drive-thru to be out as fast as possible— but I think what one needs to realize is that having their orders (literally) thrown into their car for the sake of speed of service doesn&#8217;t please the customer. They aren&#8217;t going to think, &#8220;well, golly, they threw the sandwich right into the passenger seat and refused to carry on a quick little bit of small-talk while I waited, but damn, it took only 30 seconds, so I am going to say I am satisfied&#8221;. I&#8217;m sorry, but this does not happen. As long as a customer is not waiting an exceedingly long time for their purchase, they tend not to notice it. Think of it this way- there is the old adage where you can either have fast service, good service, or right service, but you can only choose two. I put forth that, for many consumers it also holds true that when one of these is omitted, and the other two are done in a way that exceeds their expectations, they are likely to generally be satisfied. For example, if a customer is greeted with courteous fervor, and perhaps a friendly conversation ensues in addition to their order being made perfect, they are less likely to notice that they had to wait in the line for a few minutes. Now, if they had to wait that same amount of time and they were treated brashly, they are more likely to take offense. In fact, the single most important thing to almost all customers is not the time they wait, or even the fact that their order is made perfectly to their specifications, but rather to be treated as people, and not as some mindless consumer whose particular interests and concerns are of no importance. The sad fact is using this particular measurement metric encourages the workers to do the latter.</p>
<p>The thing is, there are even further flaws in the mechanism. First, the device doesn&#8217;t even work half the time, so times come out skewed and sometimes two vehicles get counted in the same interval. Additionally, since the time measured is the entire time the customer is at the window, this is not simply a measure of the efficiency of the workers to get the product to the customer but also a test of how quickly the customer can pay for their product. if a customer needs to dig for change for 10 extra seconds after the employees have successfully finished their entire order and simply await payment, why is this 10-seconds attributed to the detraction of the employees? &#8220;Because we have no way of knowing&#8221; the people who read the recorded times may say. The issue here is that obviously if there is one fact you don&#8217;t know about what the measurement indicates then there are certainly more, and in fact it could even be put forth that the measurement is completely meaningless. a Customer could be at the window for 10 seconds and still not be pleased, be it because of the shoddy service received while being squeezed through in a tiny window of time, or because they got their order mixed up with another, or some other error instigated by the fact that inhuman demands are made of people there. On the converse, a person could wait for a entire minute at the window and still be perfectly pleased with their service, so using the measure of window time as some sort of barometer by which to judge the performance of a business is downright ridiculous, and this only multiplies when one considers that such time-based constraints are not placed on those consumers who decide to enter the establishment for their service.</p>
<p>And while the latter example has certainly acquired far more attention for personal reasons, it certainly is no more or less ludicrous then the software companies implementation; performance metrics have been tried in nearly every industry and in every industry they have failed to provide the hoped for results. The key here is that the measure is not strictly of customer satisfaction or even of revenue; but more directly, of the value of the business.</p>
<p>Value is a perception and must be communicated and measured to be  perceived as value. Value measurement is the process by which management  decides on operational performance measures that will enable them to  secure the the owners return on investment. Value measures must be  aligned with the business strategy positioning the business. Measurement  includes measuring lead factors and lag factors. Lead factors identify  performance measures that will proactively provide an indication of  whether objectives will be achieved or not. Lead factors allow  management to receive warning sign proactively. Lag factors measure how  successful management was in terms of creating value. Financial reports  are the ultimate lag measures of success. When a business lead measures  indicate that the business is performing well but the business lag  factors are showing the contradictory then it is time to review the lead  measures.</p>
<p>The value measurement process determines the  behaviour of the business and aligns the behaviour of human capital with  the value expectations of all stakeholders e.g. owners,  management, customers, employees and partners. Value should be measured  and reported on from every stakeholder&#8217;s perspective. A true balanced  scorecard will drive performance improvements for all five stakeholder  dimensions. This all applies to ANY business, regardless of industry.</p>
<p>Flipping quickly back to software, an excellent overview of the problems present with Performance metrics as used in that industry can be found here: http://discuss.joelonsoftware.com/default.asp?biz.5.304155.19</p>
]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2010/02/metrics-they-simply-dont-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rooting for the ROT- or not.</title>
		<link>http://bc-programming.com/blogs/2010/02/rooting-for-the-rot-or-not/</link>
		<comments>http://bc-programming.com/blogs/2010/02/rooting-for-the-rot-or-not/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 08:44:31 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=73</guid>
		<description><![CDATA[A few minutes ago I posted a small Visual Basic 6 class module that could be used to register an applications objects in something called the &#8220;Running Object Table&#8221; Or ROT. Rather then go on a long monologue in that post I&#8217;ve decided that this is an excellent topic for a blog entry, with pictures [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">A few minutes ago I posted a small Visual Basic 6 class module that could be used to register an applications objects in something called the &#8220;Running Object Table&#8221; Or ROT. Rather then go on a long monologue in that post I&#8217;ve decided that this is an excellent topic for a blog entry, with pictures and whatnot. The forum thread I created is <a href="http://bc-programming.com/forum/index.php/topic,10.0.html">here</a>, and provides the source to a useful class module that can be used to expose your objects on the ROT.</p>
<p style="text-align: left;">In order to fully understand what the ROT is and it&#8217;s usefulness, it&#8217;s important to have a basic understanding of COM. At the moment COM is really a &#8220;legacy&#8221; technology, and Microsoft much prefers that people develop .NET assemblies instead. Of course, what MS fails to mention is that it&#8217;s unlikely that COM support will be withdrawn from any foreseeable version of windows, simply because it is so deeply rooted and so necessary for applications, including Microsoft&#8217;s. In any case, having a solid knowledge of COM is not something that is going to become useless or even irrelevant anytime soon, so it cannot hurt even a non-programmer to understand some of the basic semantics involved.</p>
<p style="text-align: left;">Originally, COM wasn&#8217;t really released with any fanfare; in fact, it was simply the &#8220;bed&#8221; upon which the more prevalent technology at the time, OLE (Object Linking and Embedding) was based. OLE really is an awesome technology, but the problem is nobody really knows how to use it. Anyway, the main idea was that each application knew how to deal with it&#8217;s own files; for example, excel knew spreadsheets, word-perfect knew word processing, etc, and the idea was that instead of trying to get applications to implement the various different application &#8220;powers&#8221; (such as having built-in word processors and the like), they could simply call on another application to do it. For example, if you made a useful chart in Excel 5.0:</p>
<div class="mceTemp mceIEcenter" style="text-align: left;">
<dl id="attachment_74" class="wp-caption  aligncenter" style="width: 712px;">
<dt class="wp-caption-dt"><a href="http://bc-programming.com/blogs/wp-content/uploads/2010/02/excel.png"><img class="size-full wp-image-74" title="excel" src="http://bc-programming.com/blogs/wp-content/uploads/2010/02/excel.png" alt="" width="702" height="400" /></a></dt>
<dd class="wp-caption-dd"><em>Dun click here for a bigger image, yee-haw</em></dd>
</dl>
</div>
<p style="text-align: left;">Now, of course you could make a chart with the spreadsheet, but let&#8217;s say you wanted to embed the spreadsheet into your word document. In pre-OLE versions of word, you could copy-paste a picture of the spreadsheet, but if you ever needed to change it you&#8217;d need to go right back to excel, find the file you originally used, make the changes, copy it, paste it, reformat the bloody document again because pasting it has totally screwed up your pagination, etc. Basically it translates to a huge pain in the ol&#8217; keester.</p>
<p style="text-align: left;">So Microsoft decided, hey, you know what, let&#8217;s make it so you can actually place the spreadsheet document itself into the word document, and you can edit the spreadsheet and have it update in the word document automatically. One of the development team leaders for excel at the time said, &#8220;that might be a bit difficult&#8221; at which point they fired him and hired somebody else. I&#8217;m making this up, obviously. the quip was more along the lines of him trying to discuss his previous extra-marital relations with the project managers mother. Or maybe it was their wife, in either case it&#8217;s generally not something you bring up around the water-cooler even in faint whispers, let alone in the middle of an important business meeting about important businessy things, like who keeps taking the bloody stapler.</p>
<p style="text-align: left;">Anyways, Microsoft eventually perfected the technology that they called OLE. (oh yeah, and just so everybody is aware, it&#8217;s apparently pronounced &#8220;olay&#8221;&#8230; so don&#8217;t try to embarass yourselves. I still personally pronounce it Ohh- Ell- eee, but hey, I&#8217;m a rebel. Also pronouncing it &#8220;olay&#8221; is just begging for jokes about &#8220;oil of OLE&#8221; or perhaps even matador references. It just feels like it was chosen for comedic reasons.)</p>
<p style="text-align: left;">using OLE, you could link your excel spreadsheet to your southern US based newspaper, by using the very popular &#8220;Copy&#8221; command from Excel, and then using &#8220;paste Special&#8221; in word, you could get the following dialog:</p>
<p style="text-align: left;"><a href="http://bc-programming.com/blogs/wp-content/uploads/2010/02/pastespecial.png"><img class="size-full wp-image-77 aligncenter" title="pastespecial" src="http://bc-programming.com/blogs/wp-content/uploads/2010/02/pastespecial.png" alt="" width="472" height="276" /></a></p>
<p style="text-align: left;">As you can see, there are a number of choices here. the relevant one to this discussion is to insert it as a &#8220;Excel 5.0 Worksheet&#8221;- the default for the two radio buttons on the side is to actually &#8220;paste&#8221; the item into the document; here I&#8217;ve chosen to paste a link. pasting the spreadsheet into the document directly (rather then linking it) still allows you to edit the spreadsheet, but the spreadsheet data itself is saved right in the word document when you save it. Because linking the object instead offers one extra point of failure and because I like living on the edge, I always opt to link the documents even if I have no good reason to.</p>
<p style="text-align: left;">In any case, the resulting newsletter is this:</p>
<p style="text-align: center;"><a href="http://bc-programming.com/blogs/wp-content/uploads/2010/02/confederatenews.png"><img class="size-medium wp-image-76   aligncenter" title="confederatenews" src="http://bc-programming.com/blogs/wp-content/uploads/2010/02/confederatenews-300x225.png" alt="" width="300" height="225" /></a></p>
<p style="text-align: left;">beautiful! such magic is the very essence of OLE. In fact, one could even take advantage of OLE in their Visual Basic Applications, starting with Version 2.0, which included, among other useless &#8220;professional&#8221; controls, the OLE client control.</p>
<div class="mceTemp mceIEcenter" style="text-align: left;">
<dl id="attachment_78" class="wp-caption  aligncenter" style="width: 670px;">
<dt class="wp-caption-dt"><a href="http://bc-programming.com/blogs/wp-content/uploads/2010/02/leetvb4.png"><img class="size-full wp-image-78" title="leetvb4" src="http://bc-programming.com/blogs/wp-content/uploads/2010/02/leetvb4.png" alt="" width="660" height="306" /></a></dt>
<dd class="wp-caption-dd">Mirror, Mirror, on the wall, whose the leetest of them all?</dd>
</dl>
</div>
<p style="text-align: left;">&#8220;But I thought this entry was about the ROT&#8221; you ask. to which I reply, shut the hell up, will you, I&#8217;ll get to that eventually, and the less you try to fictitiously interrupt me the quicker I can try to ease the topic back to the present day and the running object table. Don&#8217;t worry, I haven&#8217;t forgotten about it.</p>
<p style="text-align: left;">Anyways; as I was saying, COM was basically what this OLE magic is based on, and was in fact the &#8220;plumbing&#8221; that made OLE work. OLE was only the visual manifestation of COM; therefore it was the part that was oooh&#8217;d and ahhh&#8217;d, (although the actual response was more a hum and a haw, since nobody could really figure the bloody thing out). COM just sort of sat in the background. unnoticed, watching OLE take the spotlight, earn all the respect and get all the beautiful women and free cream soda. Microsoft created something called &#8220;OLE Controls&#8221; whereby various User Interface widgets could be created using a number of OLE Interfaces with confusing names and functions, like an IPersistFile that didn&#8217;t deal with files, IOLEActiveObject, and other weird esoteric interfaces.</p>
<p style="text-align: left;">Things started looking up with the creation of &#8220;ActiveX Controls&#8221; which are exactly the same as OLE Controls, but don&#8217;t require all the silly interfaces to be implemented (at least, not as many of them). Pretty much all you needed to implement were a few basic interfaces. With the release of Visual Basic 5.0, this task became even easier; soon enough ActiveX Controls were sprouting up out of basements everywhere with dubious security and hardly little effort or skill. Unfortunately this had the effect of backfiring on Microsoft as they had forgotten that IE3 sorta just allowed ActiveX Controls to do what they pleased; in the long run, Internet Explorer gave ActiveX a very bad name. The technology itself is sound; however, one consumer (Internet Explorer) has an awful track record when it comes to actually being intelligent with what is actually run. First MS decided, &#8220;ha! we&#8217;ll just make it so they have to sign the control as safe with this little tool&#8221; much to their surprise, the people who were doing illegal things already by creating spyware as ActiveX Controls gladly downloaded the tool and signed them, even though the EULA was quite clear that you couldn&#8217;t sign malicious files. &#8220;dear gawd! these people are MAD! mad I say! have they any idea the legal repercussions of agreeing to a shrink-wrap EULA implicitly in a completely non-legally binding way?&#8221; exclaimed&#8230; well, somebody at MS, to which the common reply was &#8220;Tom, we know you&#8217;ve been taking staplers home.&#8221;</p>
<p style="text-align: left;">In either case, ActiveX got noticed, and while IE was a massive failure when it came to using ActiveX, ActiveX was perfectly safe on the desktop itself; in fact, it&#8217;s still quite prevalent. Go ahead and look on your own windows machines- ActiveX Controls are found in &#8220;OCX&#8221; files. many are even installed by default. Because ActiveX was more a Programming technology then a silly little User Interface gimmick like OLE, programmers liked to pick apart it&#8217;s innards like a vulture likes to take it&#8217;s pick from the smorgasboard of delightful organs that are present on a freshly killed wildebeest. Programmers learned of the various COM component technologies that powered ActiveX and OLE before it.</p>
<p style="text-align: left;">It was around this time that COM itself became the &#8220;technology of choice&#8221; when it came to interoperating with the various components of windows. So much so that COM itself became deeply rooted in the Operating System; with the actual Shell interfaces that allow for such things as IE plugins and Browser helper objects and Shell Extensions being implemented as COM interfaces.</p>
<p style="text-align: left;">COM itself establishes a binary standard between modules; it essentially lays out how objects are to look in memory, so that other objects can use them. In a strange coincidence this layout was nearly identical to the way the Visual C++ compiler laid out it&#8217;s Class instances.</p>
<p style="text-align: left;">Unlike C++ itself, or java, or .NET, for example, however, COM does not really facilitate for most things that people seem to require in order for something to be &#8220;object oriented&#8221;. For example- there was no Implementation inheritance. There was interface inheritance, to be sure, but they didn&#8217;t add implementation inheritance because they believed that to replace parts of the functionality of a pre-existing class with your own while leaving parts of the original code intact requires a knowledge of what that code does beyond what you can see, and really there is no debating that fact on the level.</p>
<p style="text-align: left;">Now then, enter OLE automation, which was really just COM with a fancy name. OLE automation basically meant that you could &#8220;control&#8221; other applications from another application, completely cross-process. For example, nowadays you can write a VBScript that interfaces with Microsoft word to open a document, make changes to it, save it, and close it. This is possible through OLE automation, because the Word Program exposes itself to other applications, who, strangely enough, are not revolted by Word&#8217;s nether regions.</p>
<p style="text-align: left;">Visual Basic has allowed for the creation of ActiveX programs since Version 5; what Word would be equivalent to as a Visual basic project would be an &#8220;ActiveX EXE&#8221;. there are both ActiveX EXE and ActiveX DLL projects; they act quite similar to one another, in that the various methods of using their objects are the same in either case. the main difference between them is that an ActiveX EXE is, for obvious reasons, a completely separate process, while a ActiveX DLL is contained in the same process and every process that uses it. This means that all data passed back and forth to an ActiveX EXE needs to be marshalled across a process boundary. Very time consuming, but at the same time the EXE can perform operations asynchronously from the application itself, which, in the case of Visual Basic, really only has a single thread.</p>
<p style="text-align: left;">When a ActiveX Server program is running, the general idea is for it to add itself to something called the &#8220;Running Object Table&#8221;. This ia global table that stores all the various active COM objects that can be retrieved. For example, Word, Excel, Access, etc, all place their &#8220;Application&#8221; objects into this table.</p>
<p style="text-align: left;">Visual Basic ActiveX EXE programs, however, for whatever reason, do not. This despite Visual Basic having a function that can acquire objects <em>from</em> the running object table, the <span style="font-family: monospace;">GetObject()</span> Function.</p>
<p style="text-align: left;"><strong>GetObject</strong></p>
<p style="text-align: left;">The GetObject Function is probably one of the strangest functions with the oddest behaviour and the quirkiest set of rules of all the functions in the Visual Basic Language. The syntax seems simple enough:</p>
<pre style="text-align: left;">GetObject([Pathname],[class])
</pre>
<p style="text-align: left;">pathname, we can guess from our encounters with Excel and word with OLE, would probably accept a OLE enabled document. and lo and behold, passing a excel, word, or other OLE server application document returns that document object. the <em>class</em> parameter however requires some explanation regarding it&#8217;s background.</p>
<p style="text-align: left;">All COM objects have at least one thing associated with them; a CLSID, which I guess stands for &#8220;ClassID&#8221;, but could just as easily stand for &#8220;Chickens Like Seeds In Dung&#8221;. This CLSID is required when instantiating (creating an instance of) the object. Some objects have another, optional, more human readable representation, known as a &#8220;progid&#8221; (god knows what it stands for. I&#8217;m going to say &#8220;People Really Ought to Give It a few Days&#8221; or something. This is far easier to read then the CLSID. a ProgID might be &#8220;Excel.Application&#8221;, whereas it&#8217;s CLSID is {00024500-0000-0000-C000-000000000046} (although technically it fits in 8 bytes, this is the conventional &#8220;human readable&#8221; form of a CLSID.</p>
<p style="text-align: left;">Now, you can call me dull, dense, made of cheese or fond of yogurt, but I don&#8217;t think I&#8217;m too far off-base in saying that the progID, While having an utterly ridiculous acronym expansion that I just made up, is a lot easier to read then the CLSID.</p>
<p style="text-align: left;">In any case; the Class argument to GetObject() is actually a ProgID. So the question is; how does one call this function to get a running instance of the program? If you do:</p>
<pre style="text-align: left;">Set X=GetObject("","Excel.Application")
</pre>
<p style="text-align: left;">a <em>new</em> instance of Excel starts in the background and your given <em>it&#8217;s</em> application object. However, it turns out the first parameter is optional&#8230; you can in fact do this:</p>
<pre style="text-align: left;">set X = GetObject( ,"Excel.Application")
</pre>
<p style="text-align: left;">and your given a instance of Excel that is already running, if available. If not, you get an error. You can trap the error and perform either the former empty string version of the function call or use CreateObject() to create a new instance explicitly though, if necessary.</p>
<p style="text-align: left;">Now, given that GetObject() when used in that scenario acquires the object from the running object table, it becomes evident why it will not work for Visual Basic objects; as previously discussed, the visual basic Runtime never actually anything to the ROT. This means it&#8217;s necessary to do so yourself by explicitly adding it to the ROT using the COM API.</p>
<p style="text-align: left;">Now, although I wrote the class I describe in the forum post 5 years ago, I distinctly remember that from beginning to end only took about 30 minutes. Most of the COM code I have in there was ripped directly out of a module in my BASeEdit XP project I was working with at the time. One tool I found useful while I was working on it was a little Utility that came with Visual Studio 98 called &#8220;ROT Viewer&#8221;. Since IT doesn&#8217;t appear to be available online anywhere, I have taken the liberty of <a href="http://bc-programming.com/downloads/IROTVIEW.zip">uploading it myself.</a></p>
<p style="text-align: left;">Even the non-programmer can get a few minutes of mild amusement out of the program. With Vista and 7, you need to start the program with Administrator rights, otherwise it doesn&#8217;t show anything. Try it out; start word, excel, (I wonder if MS works has a COM server&#8230;) and any number of other programs, and watch them get added to the table, close out the programs, watch them leave&#8230; OH THE EXCITEMENT!</p>
]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2010/02/rooting-for-the-rot-or-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Variables have rights!</title>
		<link>http://bc-programming.com/blogs/2010/01/variables-have-rights/</link>
		<comments>http://bc-programming.com/blogs/2010/01/variables-have-rights/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 15:34:15 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Humour]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=67</guid>
		<description><![CDATA[I bring forth to you all an important cause. Ever since the inception of programming, we have used things called Variables. they store our data, they help us to keep track of the ever-changing environment that is where our programs stand. But how often do we think of their rights as individuals? We instead try [...]]]></description>
			<content:encoded><![CDATA[<p>I bring forth to you all an important cause.</p>
<p>Ever since the inception of programming, we have used things called Variables. they store our data, they help us to keep track of the ever-changing environment that is where our programs stand. But how often do we think of their rights as individuals? We instead try to optimize them away; &#8220;we don&#8217;t need that variable&#8221; or &#8220;we could make that a constant&#8221;. You self-centered bigots! All a variable asks is maybe a few bytes of memory, and possibly the ability to be thread synchronized, but you are trying to remove these little helpers as if they have no right to exist! consider the following:<br />
<code><br />
public class ExampleApp<br />
{<br />
private int munused;<br />
private int maddthis=56;<br />
public static main(String[] args)<br />
{<br />
System.out.Println("Hello from main");<br />
for(int i=1;i&lt;51;i++)<br />
{<br />
x /= (++x/i++)/(maddthis*--i)<br />
System.out.Println("x="+x);<br />
}</code></p>
<p>}</p>
<p>}</p>
<p>Any experienced variable killer can see that they can delete munused entirely, and that they can can convert maddthis to a constant. But what they don&#8217;t consider is that they are KILLING innocent variables! Programmers these days endeavour to learn programming practices and implement them with unfeeling and unwavering constitution, with absolutely no regard for the font families they destroy or the variables they create; it&#8217;s important to relate to your variables. your average programmer sees a temporary or unused variable as wasteful; I see a variable that is going through a scary change, who needs a friend (have you ever considered the Variables feelings when you typecast an int to a double? your just highlighting that variables shortcomings! you&#8217;re telling that variable that they are inadequate, that their data type is simply inferior to the one you are casting it to. And you know what that variable loses? It&#8217;s value. Now some other new variable is holding it&#8217;s value, and it supports floating point operations, and because of it&#8217;s type it gets twice as many bytes of storage!). Tell stories to your variables. Tell then the bible story of Variable Jesus who allowed it&#8217;s own destructor to be called, just so that all other variables can have everlasting scope. And, remember: NEVER tell your variables what their scope is. If they discover that their destructor will be called right after this quick for loop, they may go mad. &#8220;What? I only have 3 iterations left to live! I&#8217;ve lost all scope!&#8221;. Be sure your variables know their place. &#8220;All variables are created equal- it is their initialization that makes them unique&#8221;. Function Pointers have a tendency to forget that they are variables; they walk and they talk and they even have similar syntactic requirements as a function, but don&#8217;t be fooled! they are really just a variable in a functions clothing. Don&#8217;t try to call a null function pointer or the clothing has a habit of chafing.</p>
<p><strong>Object Variables</strong></p>
<p>Object Variables are possibly even worse then Function pointers. they always consider themselves superior to all the primitive types, like ints and doubles. what Object variables don&#8217;t realize is that the vtable that makes them who they are is really just a structure; a collection of function pointers. In fact, make sure your object variables know they are really just a collection of function pointers and private data. Also, educate your young object variables. &#8220;never show your privates to strangers, even if they give you memory&#8221; and never EVER let anybody put something in your back-end!</p>
<p>If you know somebody well enough, you might want to share certain protected variables with them, as a gesture of good faith. But you still should not trust them with your privates. they might still try to shove data in your back end.</p>
<p>Make sure your objects understand that they really are just the sum of their aggregate parts, and that they have their superclass to thank for almost everything. an Object is created, it is given a few pointers, and sent on it&#8217;s way.</p>
<p>Your standard pointer variables are pretty unpredictable too; remember that dereferencing, for a pointer variable, is a very traumatic experience. It&#8217;s also important to reduce aliasing as much as possible; to avoid indentity crises between multiple variables who meet and see that they both point to the same memory space. It&#8217;s important that you initialize pointers, as well. There is nothing more traumatic then a variable discovering it is equal to 0xCCCCCC or 0xDEADBEEF, and that it is really holding a flag. a flag of surrender. Unless the variable is French this won&#8217;t feel right for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2010/01/variables-have-rights/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TTMT: Teenagers with To Much Time.</title>
		<link>http://bc-programming.com/blogs/2009/12/ttmt-teenagers-with-to-much-time/</link>
		<comments>http://bc-programming.com/blogs/2009/12/ttmt-teenagers-with-to-much-time/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 09:24:45 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[hacker douchebagging]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=40</guid>
		<description><![CDATA[The scourge of the internet, really. Personally, I call them script kiddies. Essentially; they use other peoples scripts to &#8220;DoS&#8221; a website. A number of fine specimens can easily be found on youtube. For example, http://www.youtube.com/watch?v=iVfEoBPV4Nc. What makes this particular example even funnier is that they don&#8217;t even understand what is happening, AND they don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>The scourge of the internet, really. Personally, I call them script kiddies. Essentially; they use other peoples scripts to &#8220;DoS&#8221; a website. A number of fine specimens can easily be found on youtube. For example, http://www.youtube.com/watch?v=iVfEoBPV4Nc. What makes this particular example even funnier is that they don&#8217;t even understand what is happening, AND they don&#8217;t understand why they are so stupid to even try.</p>
<p>Basically, there are two levels of &#8220;hacker&#8221; now, 99.9% of them are really just script kiddies, who can hardly even understand Batch files, let alone perl. They copy and use scripts (such as the posted youtube video&#8217;s kiddie) created by the 0.1%. What makes it all the more interesting is the 0.1% people often are unaware of their code being used this way.</p>
<p>In either case, a DoS attack is so simplistic to the very core that any cheap 20$ router at the local wal-mart can block it; and any sufficiently equipped server can deal with the extra load from a single PC quite easily.</p>
<p>In this particular example, the first web-site mr.kiddie tried was obviously set to reject constant HTTP get requests. I mean- it&#8217;s not too hard to mechanically filter out GET requests that come within, say, a second of each other for the same page, and even the most basic server software implements this.</p>
<p>What happened to the second, less developed (apparently) site simply doesn&#8217;t have basic safeguards in place, perhaps because they live in a optimistic world where teenagers go out and get jobs instead of sitting on their asses all afternoon trying to take credit for copy-pasting code from other sources in programming languages they only pretend to know in order to take down some site that nobody will miss for the 10 seconds they manage to bring it down, and then they get called to dinner, where their veteran father yells at them for being so god damned lazy and for not mowing the lawn, to which the &#8220;experienced hacker&#8221; responds, &#8220;you&#8217;ll be sorry, I&#8217;m gonna start the next M$, and you will be begging for dollaz from me pops&#8221; and then he get&#8217;s grounded.</p>
<p>The &#8220;hacker&#8221;&#8230; or more precisely, the &#8220;script kiddie&#8221; culture is really quite simple, much like the social structure of one-celled organisms. You have the fat hairy parameciums, and then you have everybody else. their interactions with one another generally involve using made up english words, like &#8220;pwned&#8221;, and of course replacing as many of the letter s with z&#8217;s in a desperate attempt to look cool. Additionally, conversations often just involve them making stuff up.</p>
<p>&#8220;Hey, dawg, I just haxxored Oracle, d00d&#8221;</p>
<p>&#8220;Oh yeah, well I&#8217;ve been buyin stuff off ebay for free using my l33t skills&#8221;</p>
<p>ad infinitum. Even early on it&#8217;s absurd; I mean, my grandmother could hack an Oracle server with two toothpicks and a ceramic bowl, it&#8217;s really that easy, Hell, my second cousins guinea pig was able to drop a few tables from one of their badly administered database servers, but that&#8217;s not the point.</p>
<p>You know what? I&#8217;ve spent a good 5 years trying to shrug this shit off but I&#8217;ve grown sick and tired of putting up with arrogant, know it all little shits whose knowledge could be summarized on the head of a pin. I&#8217;m SICK of hearing about how &#8220;talented&#8221; little Billy is, and then looking at the code only to mistakenly believe little billy designed his code to emulate that mysterious sack of mould in the back of my fridge. Why do I hate this so much? Do I need a really good reason to hate it? really? because honestly I think the problem damn near hates itself, in a manner of speaking.</p>
<p>To make things worse, not only is little Billy a arrogant little prick, but his own ego is fed by his own family members, &#8220;Oh, little billy is a genius! He found the file menu in Word, He&#8217;s gonna be the next bill gates!&#8221; No, Uncle Tom, Billy Didn&#8217;t find the fucking file menu, your just too retarded to see whats right in front of you. Do I get points for pointing out a lawn chair for you to sit in when your sitting in it? No, I don&#8217;t, and I really don&#8217;t think billy should be proud of himself for pointing out the obvious, instead he should feel pity for somebody so stupid they cannot understand a basic UI and then evangelize the person who comes to point out the obvious.</p>
<p>The problem with the entire thing is, either they &#8220;have it&#8221; or they don&#8217;t, and the longer they fester, with no real skills, seated on their high pedestal because they mistakenly believe that employers will come to them after they barely graduate from high school, because of that awesome space shooter program they made in Visual Basic 2.0 and released on a shoddy geocities web site. Is the  longer they don&#8217;t gain any skills whatsoever, and the higher the chances that they will be struck down, working as a custodian in their local elementary school. Having been forced to realize that they aren&#8217;t bloody geniuses, that copy-pasting other peoples code is plagiarism, not &#8220;leet skills&#8221; and that they really, really, really, have a lot more respect for their old schools custodian.</p>
<p>Another issue- and this applies globally to programmers,software developers and those that want to pretend they are one of those two, is that they mistakenly believe they have reached a &#8220;plateau of greatness&#8221; or skill; No programmer, no matter how much experience, cannot learn something new; and it&#8217;s far too common that you have people, fresh out of college, or high school, or whatever, that think that because they read the programmers guide included with Visual basic 2.0 that they can crank out AJAX applications; this simply is not the case. It&#8217;s not a plateau- it&#8217;s a group of infinitely rising mesas, and joy of programming comes from climbing those mesas, every once in a while looking back, and realizing just how far you&#8217;ve come; just remember to do one thing before you start feeling satisfied; look up, and realize just how far you have to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2009/12/ttmt-teenagers-with-to-much-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
