A better way to code debugs

by Docfxit (Login Docfxit)
R

 
I have this code to print debugging statements throughout the program.
It looks cumbersome to me. Do you have a better way of printing
1. Text
2. A text variable
3. A numeric variable

The way it's written If I don't want var2 to print I put it equal to 999
Currently If var2 doesn't print var3$ always prints and I don't want it to.

ON ERROR GOTO ErrorHandler

debugflag$ = "Onn3" 'For debugging

ErrorHandler:
ErrorCode = ERR
Ix = Ix + 1

SELECT CASE ERR
CASE 155: LastErrorLine = _ERRORLINE
END SELECT
'*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
' This If statement works but I'd like some help in making it more efficient
' I'm sure there must be a better way to do it
IF ERR = 155 THEN 'Debug
'** Print line and variable to screen
IF var2 999 THEN
COLOR 11, 0: LOCATE Ix, 1: PRINT "On Line "; LastErrorLine; var1$; var2
ELSE
COLOR 11, 0: LOCATE Ix, 1: PRINT "On Line "; LastErrorLine; var1$; var3$
END IF
END IF
RESUME NEXT

' This If statement goes in the middle of my code when I only want text to print.
IF debugflag$ = "Onn3" THEN
var1$ = "Text Only " 'For Debuging Only
var2 = 999 'For Debuging Only
ERROR 155 'For Debuging Only
END IF

' This If statement goes in the middle of my code when I want one line of text
' and one character variable printed.
IF debugflag$ = "Onn3" THEN
var1$ = "Text and one character variable - wsFileNum = " 'For Debuging Only
var2 = wsFileNum 'For Debuging Only
ERROR 155 'For Debuging Only
END IF

' This If statement goes in the middle of my code when I want one line of text
' and one numeric variable printed.
IF debugflag$ = "Onn3" THEN
var1$ = "Text and one numeric variable - tmp$ = " 'For Debuging Only
var2 = 999 'For Debuging Only
var3$ = tmp$ 'For Debuging Only
ERROR 155 'For Debuging Only
END IF



    
This message has been edited by Docfxit on May 5, 2012 3:34 PM

Posted on May 5, 2012, 3:33 PM

Respond to this message   

Return to Index

Response TitleAuthor and Date
Is there a wayDocfxit on May 8
 Re: Is there a way on May 8
  How could I make this work?Docfxit on May 8
   * You're missing an $ on May 8
    * Thank you. That worked great.Docfxit on May 11

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement