Page 1 of 1

Odd debug.print behavior

Posted: 15 October 2009, 14:20 PM
by hakha4
Hi!
Code below works fine but after a minut or so the in buffer stops recieving data ! After trial and terror I found out that if I remove the debug.print "Waiting.." everything works as expected. I think I've read somewhere that debug.print don't effect buffer but in this case it's seems that it does. Anyone have an idea why? It's quite a challenge to find errors in programs if debug.print give you errors.



Code: Select all

'**********************************************
'****** Task called from Sub Main           ***
'****** to check if touch screen pressed ******
'**********************************************

Public Sub CheckLCDTouch_TouchResponse()
Dim tmpResponse As String
Dim tmpCommand As String
TouchRespons  = " "
Do

Call ClearQueue((CByteArray(InBuf(1, LCD_touch).DataAddress)))

tmpCommand="K" 

Call PrintText_TouchLCD(tmpCommand)' sending a 'K' tells Display to response on touch

tmpResponse = GetQueueStr((CByteArray(InBuf(1, LCD_touch).DataAddress)))
TouchRespons = mid(tmpResponse,4,1) '# or number according to touched button

Select Case TouchRespons
Case "#"'do nothing

Case "1"
Debug.print "Row 1 hit"

Sub_LCDTouch_Menu(TouchRespons)
Case "2"
Debug.print "Row 2 hit"

Sub_LCDTouch_Menu(TouchRespons)
Case "3"
Debug.print "Row 3 hit"

Sub_LCDTouch_Menu(TouchRespons)
Case "4"
Debug.print "Row 4 hit"
'back to Main menu
SubMenu = False
Main_LCDTouch_Menu


Case Else 'error,do nothing
Exit Do
End Select

'debug.print  "Waiting..." 
Call Sleep(0.1)
Loop
End Sub

Regards Hucke

Posted: 15 October 2009, 18:59 PM
by mikep
This kind of thing has happened infrequently in the past. They can be difficult to debug but it is good you have found a recreation scenario. Does it fail for a ZVM or native device (or both)?

This type of error usually occurs because of a translation problem in the ZBasic compiler. If I know Don, he is busy investigating the error and coming up with a fix.

Re: Odd debug.print behavior

Posted: 15 October 2009, 19:37 PM
by dkinzer
hakha4 wrote:Code below works fine but after a minut or so the in buffer stops recieving data !
The code that you posted doesn't compile, of course, since it's missing some data definitions at the least. It helps a lot if you can provide a complete test case that is as small as possible and still exhibits the symptom. Lacking that, you can send me the complete application (source code and .pjt file) along with some information about what external devices are connected.

Posted: 18 October 2009, 5:12 AM
by hakha4
To answer Mike's question,I'm not using native . Tested several times and debug.print did have the effect I described abowe but after making some modifications to the project I can't reproduce the error anymore! and I can't remember exactly the code that caused the error (should have made a copy!) so it must have been a special combination of code causing this.
Regards Hucke