![]() |
Forum Index : Microcontroller and PC projects : MMDEBUG suggestion
Author | Message | ||||
jirsoft![]() Guru ![]() Joined: 18/09/2020 Location: Czech RepublicPosts: 533 |
Hi Peter, couldn't be MMDEBUG made a little different way: When #MMDEBUG ON doesn't exist (or is OFF), complete row after MMDEBUG will not be included. So I can write for example MMDEBUG CLS MMDEBUG IF a=5 THEN PRINT It shouldn't be so hard and will be much more useful... Otherwise is debugging perfect way! Until now I used simple library (as DEBUG.INC), so I will not make NOT DEBUGed code slower: CONST MAX.DBG = 20 'maximal number of watched vaiables DIM STRING DBG.DBG(MAX.DBG) 'DEBUG watchlist DIM INTEGER LEN.DBG = -1 'current number of watched variables DIM INTEGER ON.DBG = 0 'DEBUG ON or OFF DIM INTEGER PERIOD.DBG = 1000 'output period in ms DIM INTEGER X.DBG=0, Y.DBG=0 'screen coordinates for output '*** SUBs and FUNCTIONs *** 'DBGon(period, x, y) switch DEBUG ON and set output to every period in ms at @(x,y) 'DBGoff switch DEBUG OFF 'DBGout print DEBUG informations 'DBGadd(variable) add var to watchlist, string var have to end with $ ' INTEGER/FLOAT var can be prefixed with &N for HEX output with N digits 'DBGdel(variable) remove var from watchlist ' SUB DBGon(period AS INTEGER, x AS INTEGER, y AS INTEGER) ON.DBG = 1 IF period = 0 THEN period = 1000 X.DBG = x:Y.DBG = y DBGout SETTICK period, DBGout, 4 END SUB SUB DBGoff ON.DBG = 0 SETTICK 0,0,4 END SUB FUNCTION DBGfind(elm AS STRING) AS INTEGER LOCAL INTEGER i, f = -1 FOR i = 0 TO LEN.DBG IF LCASE$(elm) = LCASE$(DBG.DBG(i)) THEN f = i EXIT FOR ENDIF NEXT i DBGfind = f END FUNCTION SUB DBGout LOCAL INTEGER i, h =MM.INFO(FONTHEIGHT) LOCAL STRING s, q = CHR$(34) FOR i = 0 TO LEN.DBG IF INSTR(DBG.DBG(i),"$") = 0 THEN IF LEFT$(DBG.DBG(i),1)="&" THEN 's="HEX$("+MID$(DBG.DBG(i),3)+"," + MID$(DBG.DBG(i),2,1)+")" '?s:ERROR"STOP" s = MID$(DBG.DBG(i),3) + "=" + EVAL("HEX$("+MID$(DBG.DBG(i),3)+"," + MID$(DBG.DBG(i),2,1)+")")+" " ELSE s = DBG.DBG(i) + "=" + EVAL("STR$("+DBG.DBG(i)+") ") ENDIF ELSE s = DBG.DBG(i) + "=" + q + EVAL(DBG.DBG(i)) + q+ " " ENDIF TEXT X.DBG, Y.DBG + i*h, s NEXT i END SUB SUB DBGdel(elm AS STRING) LOCAL INTEGER i, f = DBGfind(elm) IF f <> -1 THEN IF f < LEN.DBG THEN FOR i = f TO LEN.DBG DBG.DBG(i) = DBG.DBG(i+1) NEXT i ENDIF LEN.DBG = LEN.DBG - 1 ENDIF END SUB SUB DBGadd(elm AS STRING) IF DBGfind(elm) = -1 THEN IF LEN.DBG < MAX.DBG THEN LEN.DBG = LEN.DBG + 1 DBG.DBG(LEN.DBG) = elm ENDIF ENDIF END SUB Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), CMM2.fun |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
That is what it does now |
||||
jirsoft![]() Guru ![]() Joined: 18/09/2020 Location: Czech RepublicPosts: 533 |
Maybe I was not precise enough, I would like to have ANY command after MMDEBUG, right now is possible just with MMDEBUK BREAK break the code or with MMDEBUG something print something. But I thought it will be perfect to be possible: MMDEBUG CLS MMDEBUG TEXT... MMDEBUG IF a = 5 THEN PRINT something ... So I have code parts, that will be included just when needed for debugging. Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), CMM2.fun |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
No - sorry. To do it would add an extra layer to all commands which would slow normal operations down plus be a huge task. Doesn't matter with PRINT as that is an inherently slow command |
||||
jirsoft![]() Guru ![]() Joined: 18/09/2020 Location: Czech RepublicPosts: 533 |
OK, understood. I thought MMDEBUG commands are in case of #MMDEBUG OFF (or missing) replaced with ' (REM) in preprocess phase, so it will be easy. It's pity... Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), CMM2.fun |
||||
jirsoft![]() Guru ![]() Joined: 18/09/2020 Location: Czech RepublicPosts: 533 |
Can't this be built in into EDITOR? Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), CMM2.fun |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
No |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
@jirsoft you *may* be able to achieve some of what you are asking for using sptrans. If you have questions about it please start a new thread. Also I'm unable to act on any enhancement requests at the moment. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
jirsoft![]() Guru ![]() Joined: 18/09/2020 Location: Czech RepublicPosts: 533 |
If you have questions about it please start a new thread. Also I'm unable to act on any enhancement requests at the moment. Best wishes, Tom Thanks Tom, it looks good and for sure can be used for this, but I was looking for some "more standard way. When I need to change it "extern" (in app), it will be fastest way to write some small, specific tool... Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), CMM2.fun |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |