Thursday, March 29, 2007

It's in the Code

I've been coding some new tools for work so my mind is filled with an unspeakable language. Don't believe me? Despite the apparent words, you can't verbalize the punctuated syntax. Try reading this aloud:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim currentField As String
Dim currentRow As String()
File1Index = 0
PathFile1 = OpenFileDialog1.FileName
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(PathFile1)
MyReader.TextFieldType = FileIO.FieldType.Delimited
While Not MyReader.EndOfData
currentRow = MyReader.ReadFields()
File1Index = File1Index + 1
LineIndex = 0
For Each currentField In currentRow
LineIndex = LineIndex + 1
If File1Index = 1 Then
Select Case currentField
Case Is = "PartQty"
PQIndex = LineIndex
Case Is = "PartMat"
PMIndex = LineIndex
Case Is = "PartRemark"
PRemIndex = LineIndex
Case Is = "PartRemark2"
PRem2Index = LineIndex
Case Is = "PartRemark3"
PRem3Index = LineIndex
Case Is = "PartRef"
PRefIndex = LineIndex
Case Is = "PartL"
PLIndex = LineIndex
Case Is = "PartW"
PWIndex = LineIndex
End Select
Select Case LineIndex
Case Is = PQIndex
PartQty(File1Index) = currentField
Case Is = PMIndex
PartMat(File1Index) = currentField
Case Is = PRemIndex
PartRemark(File1Index) = currentField
Case Is = PRem2Index
PartRemark2(File1Index) = currentField
Case Is = PRem3Index
PartRemark3(File1Index) = currentField
Case Is = PRefIndex
PartRef(File1Index) = currentField
Case Is = PLIndex
PartL(File1Index) = currentField
Case Is = PWIndex
PartW(File1Index) = currentField
End Select
End If
Label1.Text = currentField
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message & "is not valid and will be skipped.")
End Try
End While
End Using
End Sub

Ok. It's not supposed to wrap, but you get the idea. And this is Visual Basic, so it's easier to read. It makes the tower of Babel seem like it must have been a cake walk.

This is rather simple code. More complex programming can have millions of lines of code. And we have yet to create a program as complex as the simplest self-reproducible genetic code with all of the code for the molecular machinery required for self-reproduction that would have had to be in place in order for the first molecular machinery to be made. (Oops! That's kinda circular, isn't it?) And to think, it all happened by accident. (Mff. Let me get my tongue out of my cheek.)

You know, I'm still debugging my simple program. I wonder how the first genetic code that happened on "accident" was able to debug itself...

Labels: , , ,


Post a Comment

Links to this post:

Create a Link

<< Home