Thursday, October 09, 2008

HUM Playing Reunion Show New Year's Eve 2008!!1!!

My favorite band HUM, who broke up years ago, is playing a show new years eve at The Double Door.  What is even SUPER MORE AWESOMER is that they're playing with one of my favorite existing bands The Life and Times.  My wonderful wife actually found out about the show looking for a birthday present for me.  I can't believe that I didn't hear about this sooner.  I got my tickets and will commence preparations for rock!  Science!  Loud guitar!  Open bar!  Our tickets are ordered.

"I'll send you flowers made of silent tiny pieces of the sun." - HUM

Visual Basic 6 Support for Microsoft's LOC Counter

Microsoft has released a great free lines-of-code (LOC) counter.  It is available for download here: http://code.msdn.microsoft.com/LOCCounter

The tool, however, doesn't come with VB6 support.  As much as I hate VB6, we still have a ton of it where I work.  Luckily, the tool is extensible and by editing the LineCounters.xml file and creating some regular expressions I was able to get it to work pretty well with VB6.  The LineCounters.xml file is installed in the same directory as the program.  Open it in your favorite text editor and plop in the following lineCounter section (after one of the /lineCounter closing tags of course):

<lineCounter name="VB6">

  <fileExtension>cls</fileExtension>

  <fileExtension>bas</fileExtension>

  <fileExtension>frm</fileExtension>

  <fileExtension>dsr</fileExtension>

  <codeArea name="Blank lines" isCode="false">

    <expression>^\s*$</expression>

  </codeArea>

  <codeArea name="' comments" isCode="false">

    <expression>^\s*'.*$</expression>

  </codeArea>

  <codeArea name="VB6 Class and Form Garbage" isCode="false" multiLine="true">

      <startExpression>^VERSION\s.*$</startExpression>

      <endExpression>^Option Explicit.*$</endExpression>

  </codeArea>

  <codeArea name="VB6 File Attributes" isCode="false">

      <expression>^Attribute\s.*$</expression>

  </codeArea>

  <codeArea name="VB6 Option Explicits" isCode="false">

      <expression>^Option Explicit.*$</expression>

  </codeArea>

  <pspMetricArea name="Class" toCount="true" caseSensitive="false" >

    <pspMetricAreaStartFlag>'(\W)*PSP_METRICS_CLASS_BEGIN</pspMetricAreaStartFlag>

    <pspMetricAreaEndFlag>'(\W)*PSP_METRICS_CLASS_END</pspMetricAreaEndFlag>

    <PspMetricNameFlag>(?&lt;=PSP_METRICS_CLASS_BEGIN(\W)*:(\W)*)(\w)*</PspMetricNameFlag>

    <ObjectType>(?&lt;=&lt;Object_Type&gt;(\W)*:(\W)*)(\w)*</ObjectType>

  </pspMetricArea>

  <pspMetricArea name="Method" toCount="true" caseSensitive="false" >

    <pspMetricAreaStartFlag>'(\W)*PSP_METRICS_METHOD_BEGIN</pspMetricAreaStartFlag>

    <pspMetricAreaEndFlag>'(\W)*PSP_METRICS_METHOD_END</pspMetricAreaEndFlag>

    <PspMetricNameFlag>(?&lt;=PSP_METRICS_METHOD_BEGIN(\W)*:(\W)*)(\w)*</PspMetricNameFlag>

    <ObjectType>(?&lt;=&lt;Object_Type&gt;(\W)*:(\W)*)(\w)*</ObjectType>

  </pspMetricArea>

</lineCounter>

Note that for this to work properly to remove the garbage at the top of a form file the forms must have "Option Explicit" in them.  This worked for me as that has always been a standard.  Hopefully it is useful for someone else.