[comp.sys.mac.programmer] How to tell if the Think C Debugger's active

minow@thundr.dec.com (Fortran for Precedent) (11/02/88)

I have a program that "almost" works: just the debugging left to do.
Being a cautious person, I've left a number of DebugStr() calls in
the code that trap when something unusual (such as an I/O or out-of-memory
error) occurs.  Since the people testing my program don't have access
to the sources, the occasional traps are disconcerting.

I've fixed the problem by checking that the Think C debugger's linked
in before calling Debugger() and DebugStr().  The conditioning variable
is set at program startup by means of the following ugly hack:

	menu = GetMHandle(1);			/* Apple Menu		*/
	enable_debugger = FALSE;
	for (i = 1; i <= CountMItems(menu); i++) {
	    Str255		item;

	    GetItem(menu, i, item);
	    if (EqualString(item, "\pTHINK C Debugger", TRUE, TRUE)) {
		enable_debugger = TRUE;
		break;
	    }
	}

Martin Minow
minow%thundr.dec@decwrl.dec.com