The Trace command provides a convenient way to display and collect variable values when debugging. It is intended to only be used for debugging and not activated in production software. Even though traces produce output they are not considered to have side effects. You can use traces in functions and Pure procedures.
In its simplest form the arguments are a list of variable names. You can also include quoted text that gets written as is. The command is enabled unless a slash follows the Trace verb. Without the slash the Trace is executed. Additional features conditionally enable and disable Traces.
trace [/] {Quote | (Variable ['|' Format])}, ...
When executed the output has the form:
procedure@line: variable=value ...
In output, "procedure@", is the name of the procedure containing the trace command and "line" is the source line number where the Trace was coded. This next example Traces a text variable and an integer in decimal in hexadecimal:
trace "Made it!", name, i, i|h#
When the trace is executed it would display something like this:
some_procedure@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.