Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 05:41 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MMDEBUG suggestion

Author Message
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 01:49pm 17 Nov 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10315
Posted: 02:00pm 17 Nov 2020
Copy link to clipboard 
Print this post

  Quote  When #MMDEBUG ON doesn't exist (or is OFF), complete row after MMDEBUG will not be included.


That is what it does now
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 03:32pm 17 Nov 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  When #MMDEBUG ON doesn't exist (or is OFF), complete row after MMDEBUG will not be included.


That is what it does now


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 Kingdom
Posts: 10315
Posted: 03:41pm 17 Nov 2020
Copy link to clipboard 
Print this post

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 Republic
Posts: 533
Posted: 06:29pm 17 Nov 2020
Copy link to clipboard 
Print this post

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 Republic
Posts: 533
Posted: 06:30pm 17 Nov 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10315
Posted: 07:29pm 17 Nov 2020
Copy link to clipboard 
Print this post

No
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 08:01pm 17 Nov 2020
Copy link to clipboard 
Print this post

@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 Republic
Posts: 533
Posted: 07:50am 18 Nov 2020
Copy link to clipboard 
Print this post

  thwill said  @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


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
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025