fej64
June 22nd, 2001, 07:21 AM
When i take out a debug statement the program ceases to work. But it works flawlessly with the statement inside (and the debug window open. If you close the debug window it will fail again). Its not erroring out, just reading funky data from the comm port. HELP!
Please email me if you find anything!!
jeff gladnick
bktraderstaff@yahoo.com
------------------------------------------
Private Sub MSComm1_OnComm()
Static Jcount As Integer 'Controls how many lines of input we will read
Dim JCurrentRow As String 'Accumulated string that is entered into test.txt
Dim CheckPoint As Boolean 'Conditional Logic for Inner Do Loop
Dim BufferChar As String 'Current Character in the MSComm1.input RCX buffer
Dim TempFileString As String 'Temporary String to store file data in before database
Dim i As Integer
Select Case MSComm1.CommEvent 'If data is being recieved from
Case comEvReceive 'the COMM port .....
Do While MSComm1.InBufferCount <> 0 And MSComm1.PortOpen = True ' Outer loop.
BufferChar = MSComm1.Input 'Set equal to char in Buffer
'Debug.Print MSComm1.InBufferCount
' Debug.Print BufferChar; <------- Here is the problem statement
If BufferChar = Chr(13) Then 'If data from serial port is a ...
CurrentRowDisplay.Text = JCurrentRow 'Display Current Row to form textbox
Open "test.txt" For Append As #1 'After a is encountered, Open
Print #1, JCurrentRow 'The test.txt file and write then line
' Debug.Print ">"; JCurrentRow
Close #1 'to it. Then close the file
Jcount = 1 + Jcount 'increment counter
CurrentlyAt.Text = Jcount 'Display to user the value of counter
Debug.Print "Index:"; Jcount 'Debug stuff
End If
JCurrentRow = JCurrentRow + BufferChar 'Add character in buffer to string
If Jcount = NumOfLines Then 'If the counter has reached its limit
' MSComm1.PortOpen = False
' Text1.Text = "Done!"
Open "test.txt" For Input As #2 'Open Test.txt file and then
Do While Not EOF(2) ' Loop until end of file.
Line Input #2, TempFileString ' Read line into variable.
Open "BigData.txt" For Append As #3 'Open big database for input
Print #3, TempFileString 'Append the temporary data to larger database
Close #3 'Close the file
TempFileString = "" 'Clear the tempfile string
Debug.Print TextLine ' Print to Debug window.
Loop
Close #2 ' Close file.
Open "test.txt" For Output As #4 'Open Test.txt file and then
' Write #4, 'Remove all contents of temp file
Close #4 'Close test.txt
'TempFileString = LOF(2) 'Store it in a temporary string
Jcount = 0 'Reset Jcount so it may start over
Exit Do
End If
Loop
End Select
End Sub
Please email me if you find anything!!
jeff gladnick
bktraderstaff@yahoo.com
------------------------------------------
Private Sub MSComm1_OnComm()
Static Jcount As Integer 'Controls how many lines of input we will read
Dim JCurrentRow As String 'Accumulated string that is entered into test.txt
Dim CheckPoint As Boolean 'Conditional Logic for Inner Do Loop
Dim BufferChar As String 'Current Character in the MSComm1.input RCX buffer
Dim TempFileString As String 'Temporary String to store file data in before database
Dim i As Integer
Select Case MSComm1.CommEvent 'If data is being recieved from
Case comEvReceive 'the COMM port .....
Do While MSComm1.InBufferCount <> 0 And MSComm1.PortOpen = True ' Outer loop.
BufferChar = MSComm1.Input 'Set equal to char in Buffer
'Debug.Print MSComm1.InBufferCount
' Debug.Print BufferChar; <------- Here is the problem statement
If BufferChar = Chr(13) Then 'If data from serial port is a ...
CurrentRowDisplay.Text = JCurrentRow 'Display Current Row to form textbox
Open "test.txt" For Append As #1 'After a is encountered, Open
Print #1, JCurrentRow 'The test.txt file and write then line
' Debug.Print ">"; JCurrentRow
Close #1 'to it. Then close the file
Jcount = 1 + Jcount 'increment counter
CurrentlyAt.Text = Jcount 'Display to user the value of counter
Debug.Print "Index:"; Jcount 'Debug stuff
End If
JCurrentRow = JCurrentRow + BufferChar 'Add character in buffer to string
If Jcount = NumOfLines Then 'If the counter has reached its limit
' MSComm1.PortOpen = False
' Text1.Text = "Done!"
Open "test.txt" For Input As #2 'Open Test.txt file and then
Do While Not EOF(2) ' Loop until end of file.
Line Input #2, TempFileString ' Read line into variable.
Open "BigData.txt" For Append As #3 'Open big database for input
Print #3, TempFileString 'Append the temporary data to larger database
Close #3 'Close the file
TempFileString = "" 'Clear the tempfile string
Debug.Print TextLine ' Print to Debug window.
Loop
Close #2 ' Close file.
Open "test.txt" For Output As #4 'Open Test.txt file and then
' Write #4, 'Remove all contents of temp file
Close #4 'Close test.txt
'TempFileString = LOF(2) 'Store it in a temporary string
Jcount = 0 'Reset Jcount so it may start over
Exit Do
End If
Loop
End Select
End Sub