Trace Command

The Trace command provides a convenient way to display and collect variable values when debugging. It is intended to only be used for debugging; not in production software. Even though it produces output it is not considered to have side effects. You can use traces in functions and pure methods.

In its simplest form the arguments are a list of variable names. You can also include quoted text, which will be written as is. The command is enabled when an "on" switch is coded. By removing the "on" switch the command is ignored. All traces can be disabled by a compiler switch as well.

   trace [`on]  variable [| format], ...

When executed the output has the form:

   method@line:  variable=value ...

Method is the name of the method containing the trace command and Line is the source line number where the trace occurs. This next example traces a text variable and an integer in decimal in hexadecimal:

   trace`on  "Made it!", name, i, i|h#

When the trace is executed it would display something like this:

   some_method@34: Made it! Name="Foo Bar" I=999 I=3e7

By default traces are directed to the standard error stream. Additional capabilities allow you to trace to a log file or a circular buffer. Traces can be conditional and also programmatically enabled or disabled.

Print Command

Input Command