TESTPAUSE and TESTECHO commands for debugging & minor changes

#1
Versions of ECHO and PAUSE that can be turned on and off for development and debugging purposes.

I would not just add switches, etc., to those commands, because having TEST in front of the name will make its purpose very obvious.

I do realize these could be done with aliases, IF {condition} GOTO {a label past a group of ECHO commands}, etc.

I also realize that the IDE provides a much richer environment.

That being said ...

Often "some minor bug" shows up or you just want to see if a bunch of SET commands are setting variables properly, or you want to pause after certain commands/subroutines to see output, etc. Of course, a quick method when coding is to just add temporary ECHO or PAUSE commands.

These would work this way:

TESTPAUSE /OFF -- disables all TESTPAUSE commands
TESTPAUSE /ON -- activates TESTPAUSE

Default is TESTPAUSE /OFF

Same for TESTECHO

Usage:

TESTPAUSE /ON
TESTECHO /ON

SET MyVar=%filename
GOSUB MySubrou

TESTPAUSE
TESTECHO MyVar: %MyVar

TESTPAUSE /OFF

SET filename=NO MORE FILES
TESTECHO %filename

TESTECHO /OFF
 
Last edited:
Likes: rps
#2
Perhaps have these set TCC internal variables _testpause and _testecho. That way it wouldn't even be necessary to modify a program by adding, removing, or changing TESTPAUSE ON lines.

I'm not saying don't use TESTPAUSE ON/OFF and TESTECHO ON/OFF. I'm saying make it an additional way to control those.

Might variables also require TESTPAUSE OVERRIDE and TESTECHO OVERRIDE ? I.e., "Ignore the _test variable and just go with whatever the TESTPAUSE parameter is."
 
#3
A user could his own (without GOTO) with very little effort, and with a personal touch. Below I use the variable "debug" (1= pause, 2 = echo, 3 = both). I could have used _TESTECHO and _TESTPAUSE and in my library routines, "IF DEFINED ...".

Code:
v:\> library /f
TESTECHO {
if not defined debug quit
if %debug GT 1 echo %$
}

TESTPAUSE {
if not defined debug quit
if %@eval[%debug mod 2] == 1 pause %$
}

v:\> set debug=0 & testecho foo & testpause pausing ...

v:\> set debug=1 & testecho foo & testpause pausing ...
pausing ...

v:\> set debug=2 & testecho foo & testpause pausing ...
foo

v:\> set debug=3 & testecho foo & testpause pausing ...
foo
pausing ...
 
Likes: rps

rps

Jul 6, 2008
300
4
#4
  • rps

    rps

Vince. I've been using "If defined debug ...." for awhile. Your Library function is more versatile and elegant.
Thanks for sharing.
 
#5
As I've pointed out before in other suggestions, problems with "roll your own" are that everybody will have their own version, there won't be any Help, etc.

This isn't really intended as a "heavy-duty development tool". It's really a "quick-and-dirty" approach for minor debugging or quickie testing of minor changes. Today I was testing a change I had made and I added a few PAUSE and ECHO commands to see what was going on and I thought, "Hey, why not have TESTECHO and TESTPAUSE commands, since this is a common approach?"

Implementing the basic TESTPAUSE and TESTECHO should be quite simple--they're basically, just check whether the status is /ON or /OFF. If it's /ON, hand everything off to the regular command. If it's /OFF, do nothing.

The only minor complication in adding it to TCC would be adding the /ON /OFF switch.

Regarding adding internal variables, I mention that because it's something the person adding it to TCC might want to consider. There would need to be some variable to track the /ON /OFF status, so should that be completely internal, or available to the person doing the testing?
 
#6
As I've pointed out before in other suggestions, problems with "roll your own" are that everybody will have their own version, there won't be any Help, etc.
If it's built-in then it will be one-size-fits-all. It's such a simple thing to do that I'm confident that the few who want such a mechanism will be quite capable of devising their own, tailored to what they want and need, and probably easier to use.
 
#7
Vince. I've been using "If defined debug ...." for awhile. Your Library function is more versatile and elegant.
Thanks for sharing.
Here's another, utterly simple, but it could be made as elaborate as desired.

Code:
c:\apps\tc23\library> library /f debug
DEBUG {
if defined debug %$
}

c:\apps\tc23\library> debug echo foo

c:\apps\tc23\library> debug pause pausing ...

c:\apps\tc23\library> set debug=1

c:\apps\tc23\library> debug echo foo
foo

c:\apps\tc23\library> debug pause pausing ...
pausing ...
 
#9
If it's built-in then it will be one-size-fits-all. It's such a simple thing to do that I'm confident that the few who want such a mechanism will be quite capable of devising their own, tailored to what they want and need, and probably easier to use.
There's nothing to stop people from making something more elaborate. I wasn't about to go writing and testing two whole new auxiliary programs and then tying them into the program I was checking, just to have 1 variable temporarily displayed and pause a program momentarily in two places because some kind of error message was displaying and then the screen was clearing when the program ended.

Regarding "easier to use", I can't see something much easier than adding:

TESTPAUSE /ON

...

TESTPAUSE

...
TESTPAUSE /OFF