Odd debug.print behavior

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
hakha4
Posts: 47
Joined: 01 June 2009, 21:23 PM
Location: Moholm Sweden

Odd debug.print behavior

Post 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
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Post 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.
Mike Perks
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Odd debug.print behavior

Post 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.
- Don Kinzer
hakha4
Posts: 47
Joined: 01 June 2009, 21:23 PM
Location: Moholm Sweden

Post 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
Post Reply