# MX\_DEBUG

> [HTML Version](mx_debug.htm)

_Updated October 2025_

**xcall MIAMEX, MX\_DEBUG, opcode, debuglevel \{, traceminlvl, tracetags, traceoutput, traceprefix\}.**

MX\_DEBUG (MIAMEX 144) queries or sets the [DEBUG](debugsystemvariable.md) control variable, along with several options related to TRACE and DEBUG statements. It is mainly used by SET.LIT.

**Parameters**

_opcode_  ([Num](num.md)[)](num.md)  \[in\]

0 (MXOP\_GET) to retrieve the current value of the other parameters or 1 (MXOP\_SET) to set them.

_debuglevel_  ([Num](num.md)[)](num.md)  \[in/out\]

for _opcode_ 0, returns the current value of the DEBUG control variable.  For _opcode_ 1, supplies the new value you want to set.

_traceminlvl_  ([Num](num.md)[)](num.md)  \[in/out\]

returns or sets the minimum DEBUG value for activating TRACE and DEBUG statements by level.  See Comments below for details.

_tracetags_  ([String](string.md))  \[in/out\]

returns or sets the current list (comma-delimited) of tags used to activate TRACE and DEBUG statements.  See Comments for details.

_traceoutput _ ([String](string.md))  \[in/out\]

returns or sets the output destination for TRACE and DEBUG statements. See DEBUG Settings for available options (\$WIN, \$TTY, ...)

_traceprefix _ ([String](string.md))  \[in/out\]

returns or sets the current list of macros added to those hard-coded in any applicable TRACE and DEBUG statements.  See Comments for details.

**Comments**

The DEBUG control variable is useful for embedding debugging code into applications that can be enabled or disabled without modifying the programs. Other ways to modify the variable are via the SET DEBUG command or by compiling with the /DEBUG compile switch. Ways to use the variable within a program include:

IF DEBUG THEN …

IF DEBUG > N THEN …

DEBUG.OPEN              \! open System Messages window (if DEBUG variable set)

DEBUG.PRINT msg         \! output msg to debug window (if DEBUG variable set)

DEBUG.PAUSE msg         \! output msg and wait (if DEBUG variable set)

DEBUG.CLOSE             \! close System Messages window (if DEBUG variable set)

TRACE.PRINT (level, tags) var-or-expr, ...        \! output trace, subject to activation and prefix criteria

The general form of the TRACE.PRINT statement shown above includes two activation parameters (_level_ and _tags_) which, along with the options managed by MX\_DEBUG, determine whether the particular trace will be enabled at runtime. Specifically, the level value in the TRACE.PRINT statement must be less than or equal to the system DEBUG level (set by _debuglevel_) and greater than or equal to _traceminlvl_ AND/OR one of the tracetags must match one of the tags; if tracetags starts with "+", then OR, else AND. If the statement gets enabled, any _traceprefix_ macros (e.g. \$#, \$T, etc.) will be used to augment any hard-coded into the TRACE.PRINT statement. 

**See Also**

•	[SET.LIT](debugsettings.md)[ (SET DEBUG xxx)](debugsettings.md)

•	[TRACE and DEBUG statements](trace_statements.md)

•	[Event Tracing](eventtracing.md) for more information on the System Messages window.

**History**

2023 September, A-Shell 6.5.1744:  add traceprefix parameter to support querying and setting global tracing prefix. 