If at first you don't succeed...
-
While trying to debug some legacy code, I ran into this unique take on an infinite loop:
''' ''' Initializes the trouble ticket display for stations ''' Public Sub initalizeTTick(ByVal stationID As String) 'Database Dim db As New LabConsoleDB() Try Dim dr As DataRow = db.StationDetailedRecord(stationID) If dr Is Nothing Then Return 'Populate the textbox for the trouble ticket txtTTick.Text = "Location:" & vbTab & stationID("stnName").ToString().ToUpper() & vbCrLf txtTTick.Text = txtTTick.Text & "Model:" & vbTab & dr("machManuf").ToString() & " " & dr("machModel").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "Serial:" & vbTab & stationID("machSerial").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "ICN:" & vbTab & dr("machICN").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "" & vbCrLf txtTTick.Text = txtTTick.Text & "Problem:" & vbTab & vbCrLf lblStnName.Text = dr("stnName").ToString().ToUpper() 'Show the form Me.StartPosition = FormStartPosition.CenterScreen Me.Show() Catch Call initalizeTTick(stationID) End Try End Sub
-
While trying to debug some legacy code, I ran into this unique take on an infinite loop:
''' ''' Initializes the trouble ticket display for stations ''' Public Sub initalizeTTick(ByVal stationID As String) 'Database Dim db As New LabConsoleDB() Try Dim dr As DataRow = db.StationDetailedRecord(stationID) If dr Is Nothing Then Return 'Populate the textbox for the trouble ticket txtTTick.Text = "Location:" & vbTab & stationID("stnName").ToString().ToUpper() & vbCrLf txtTTick.Text = txtTTick.Text & "Model:" & vbTab & dr("machManuf").ToString() & " " & dr("machModel").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "Serial:" & vbTab & stationID("machSerial").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "ICN:" & vbTab & dr("machICN").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "" & vbCrLf txtTTick.Text = txtTTick.Text & "Problem:" & vbTab & vbCrLf lblStnName.Text = dr("stnName").ToString().ToUpper() 'Show the form Me.StartPosition = FormStartPosition.CenterScreen Me.Show() Catch Call initalizeTTick(stationID) End Try End Sub
Oooh. So - if I fail, I try me again and again. Well that's nice and defensive. I assume that the user sees a MessageBox saying Time Remaining. 1 second for the next 4 hours.
Deja View - the feeling that you've seen this post before.
-
Oooh. So - if I fail, I try me again and again. Well that's nice and defensive. I assume that the user sees a MessageBox saying Time Remaining. 1 second for the next 4 hours.
Deja View - the feeling that you've seen this post before.
Well, being recursive it'll blow the stack... and the
catch
will fire again? -
Well, being recursive it'll blow the stack... and the
catch
will fire again?PIEBALDconsult wrote:
and the catch will fire again
Hehe I read that as 'will catch fire again'!
I have no blog...
-
PIEBALDconsult wrote:
and the catch will fire again
Hehe I read that as 'will catch fire again'!
I have no blog...
Mmm... fire...
-
While trying to debug some legacy code, I ran into this unique take on an infinite loop:
''' ''' Initializes the trouble ticket display for stations ''' Public Sub initalizeTTick(ByVal stationID As String) 'Database Dim db As New LabConsoleDB() Try Dim dr As DataRow = db.StationDetailedRecord(stationID) If dr Is Nothing Then Return 'Populate the textbox for the trouble ticket txtTTick.Text = "Location:" & vbTab & stationID("stnName").ToString().ToUpper() & vbCrLf txtTTick.Text = txtTTick.Text & "Model:" & vbTab & dr("machManuf").ToString() & " " & dr("machModel").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "Serial:" & vbTab & stationID("machSerial").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "ICN:" & vbTab & dr("machICN").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "" & vbCrLf txtTTick.Text = txtTTick.Text & "Problem:" & vbTab & vbCrLf lblStnName.Text = dr("stnName").ToString().ToUpper() 'Show the form Me.StartPosition = FormStartPosition.CenterScreen Me.Show() Catch Call initalizeTTick(stationID) End Try End Sub
Public Sub initalizeTTick(ByVal stationID As String)
stationID("stnName").ToString().ToUpper()
What the hell is that suppose to do?
-
Well, being recursive it'll blow the stack... and the
catch
will fire again?Isn't StackOverflowException one of those exception that doesn't get cought in ordinary catch? edit: Indeed it is (in .NET 2.0) Clickey[^] -- modified at 6:59 Wednesday 19th September, 2007
[My Blog]
"Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - RĂ¼diger Klaehn
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe -
Public Sub initalizeTTick(ByVal stationID As String)
stationID("stnName").ToString().ToUpper()
What the hell is that suppose to do?
-
While trying to debug some legacy code, I ran into this unique take on an infinite loop:
''' ''' Initializes the trouble ticket display for stations ''' Public Sub initalizeTTick(ByVal stationID As String) 'Database Dim db As New LabConsoleDB() Try Dim dr As DataRow = db.StationDetailedRecord(stationID) If dr Is Nothing Then Return 'Populate the textbox for the trouble ticket txtTTick.Text = "Location:" & vbTab & stationID("stnName").ToString().ToUpper() & vbCrLf txtTTick.Text = txtTTick.Text & "Model:" & vbTab & dr("machManuf").ToString() & " " & dr("machModel").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "Serial:" & vbTab & stationID("machSerial").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "ICN:" & vbTab & dr("machICN").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "" & vbCrLf txtTTick.Text = txtTTick.Text & "Problem:" & vbTab & vbCrLf lblStnName.Text = dr("stnName").ToString().ToUpper() 'Show the form Me.StartPosition = FormStartPosition.CenterScreen Me.Show() Catch Call initalizeTTick(stationID) End Try End Sub
:laugh::laugh::laugh::laugh: Are they still employeed?
INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
-
While trying to debug some legacy code, I ran into this unique take on an infinite loop:
''' ''' Initializes the trouble ticket display for stations ''' Public Sub initalizeTTick(ByVal stationID As String) 'Database Dim db As New LabConsoleDB() Try Dim dr As DataRow = db.StationDetailedRecord(stationID) If dr Is Nothing Then Return 'Populate the textbox for the trouble ticket txtTTick.Text = "Location:" & vbTab & stationID("stnName").ToString().ToUpper() & vbCrLf txtTTick.Text = txtTTick.Text & "Model:" & vbTab & dr("machManuf").ToString() & " " & dr("machModel").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "Serial:" & vbTab & stationID("machSerial").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "ICN:" & vbTab & dr("machICN").ToString() & vbCrLf txtTTick.Text = txtTTick.Text & "" & vbCrLf txtTTick.Text = txtTTick.Text & "Problem:" & vbTab & vbCrLf lblStnName.Text = dr("stnName").ToString().ToUpper() 'Show the form Me.StartPosition = FormStartPosition.CenterScreen Me.Show() Catch Call initalizeTTick(stationID) End Try End Sub
You might want to create a trouble ticket for that error.... but i suggest you use a different program to log it :) just in case theres a problem when you initialize it :)