---
rexxpub:
  defaults: rony.yaml
  logo: oorexx
---

<!-- 070_ooRexx_trace_debug_V14.odp (2026-10-15 09:37) -->

<!-- slide # 1 (2026-10-15 09:37) ----------------------------- ODP slide # 1 -->
. slide cover
# Procedural and Object-oriented Programming 6

. subtitle
**Trace (Debug)**

. cover-art
. picture img/070_ooRexx_trace_debug_V14/p01-diagram-7.png

<!-- slide # 2 (2026-10-15 09:37) ----------------------------- ODP slide # 2 -->
. slide logo=rexx reference="Cf. rexxref.pdf (2.29. TRACE, 7.4.66. TRACE)"
# TRACE – How Does Your Code Execute?

. click
- Understanding what your Rexx program does
    . after
    - Sometimes coding errors cannot be understood easily
    . click
    - Keyword statement **TRACE** and built-in function (BIF) **TRACE()**
        . after
        - Allows to temporarily have Rexx show in detail how it executes your statements
        . after
        - Allows to enter interactive mode that allows to inspect a specific location in your code
    . click
    - Most important options

      . plain steps level=2
      | | |
      |---|---|
      | **N** | normal trace setting, only traces failures in commands |
      | **A** | show all statements that get executed |
      | **R** | show all statements and their final results |
      | **I** | show in detail all intermediate steps when executing a statement |

    . click
    - Prefixing an option with a question mark (**?**) causes **TRACE** to become interactive and to trace statements step by step at each press of the *\<enter\>* key
        . after
        - Enter "**trace n**" to return to normal execution and stop interactive trace

<!-- slide # 3 (2026-10-15 09:37) ----------------------------- ODP slide # 3 -->
. slide reference="Cf. rexxref.pdf (2.29. TRACE, 7.4.66. TRACE)"
# TRACE N – Example, 1

. after
- Simple program, run twice with different output, default option **N**
    . after
    - Values change per run because of using the Rexx **random()**-BIF

. after level=2
```rexx
/* default: "trace normal" in effect */
a=100+20
b=100+random(10,99)
say "a*b:" a*b
```

. click level=2
Output of run # 1:

. with level=2
```output
a*b: 16800
```

. click level=2
Output of run # 2:

. with level=2
```output
a*b: 17400
```

<!-- slide # 4 (2026-10-15 09:37) ----------------------------- ODP slide # 4 -->
. slide reference="Cf. rexxref.pdf (2.29. TRACE, 7.4.66. TRACE)"
# TRACE A – Example, 2

. after
- Running the program with **TRACE A**
    . after
    - Option **A** traces all statements (clauses) before execution

. after group level=2
. after mark 1 pen=1
```rexx { .numberLines }
trace a     /* show all statements */
a=100+20
b=100+random(10,99)
say "a*b:" a*b
```

. end group

. click label level=2
Output:

. after steps=1,2,3,4 each=click level=2
```output
     2 *-* a=100+20
     3 *-* b=100+random(10,99)
     4 *-* say "a*b:" a*b
a*b: 17040
```

<!-- slide # 5 (2026-10-15 09:37) ----------------------------- ODP slide # 5 -->
. slide reference="Cf. rexxref.pdf (2.29. TRACE, 7.4.66. TRACE)"
# TRACE R – Example, 3

. after
- Running the program with **TRACE R**
    . after
    - Option **R** traces all statements (clauses) and their final results

. after group level=2
. after mark 1 pen=1
```rexx { .numberLines }
trace r     /* show results */
a=100+20
b=100+random(10,99)
say "a*b:" a*b
```

. end group

. click label level=2
Output:

. after steps=1-2,3-4,5-6,7 each=click level=2
```output
     2 *-* a=100+20
       >>>   "120"
     3 *-* b=100+random(10,99)
       >>>   "113"
     4 *-* say "a*b:" a*b
       >>>   "a*b: 13560"
a*b: 13560
```

<!-- slide # 6 (2026-10-15 09:37) ----------------------------- ODP slide # 6 -->
. slide reference="Cf. rexxref.pdf (2.29. TRACE, 7.4.66. TRACE)"
# TRACE I – Example, 4

. columns 6 6

. after
- Running the program with **TRACE I**
    . after
    - Option **I** traces all intermediate results

. after level=2
. after mark 1 pen=1
```rexx { .numberLines }
trace i     /* show intermediates */
a=100+20
b=100+random(10,99)
say "a*b:" a*b
```


. next column

. click label
Output:

. after steps=7-16,17-23,24 each=click
```output
     2 *-* a=100+20
       >L>   "100"
       >L>   "20"
       >O>   "+" => "120"
       >>>   "120"
       >=>   A <= "120"
     3 *-* b=100+random(10,99)
       >L>   "100"
       >L>   "10"
       >A>   "10"
       >L>   "99"
       >A>   "99"
       >F>   RANDOM => "98"
       >O>   "+" => "198"
       >>>   "198"
       >=>   B <= "198"
     4 *-* say "a*b:" a*b
       >L>   "a*b:"
       >V>   A => "120"
       >V>   B => "198"
       >O>   "*" => "23760"
       >O>   " " => "a*b: 23760"
       >>>   "a*b: 23760"
a*b: 23760
```

. end columns

<!-- slide # 7 (2026-10-15 09:37) ----------------------------- ODP slide # 7 -->
. slide reference="Cf. rexxref.pdf (2.29. TRACE, 7.4.66. TRACE)"
# TRACE I, TRACE N – Example, 5

. after
- Running the program with **TRACE I** for tracing a single statement
    . after
    - **TRACE N** gets used to reset tracing to the default

. after group level=2
. after mark 2 pen=1
. after mark 4 pen=1
```rexx { .numberLines }
a=100+20
trace i     /* show intermediates */
b=100+random(10,99)
trace n     /* reset to normal    */
say "a*b:" a*b
```

. end group

. click label level=2
Output:

. after steps=1-10,11,12 each=click
```output
     3 *-* b=100+random(10,99)
       >L>   "100"
       >L>   "10"
       >A>   "10"
       >L>   "99"
       >A>   "99"
       >F>   RANDOM => "80"
       >O>   "+" => "180"
       >>>   "180"
       >=>   B <= "180"
     4 *-* trace n     /* reset to normal    */
a*b: 21600
```

<!-- slide # 8 (2026-10-15 09:37) ----------------------------- ODP slide # 8 -->
. slide reference="Cf. rexxref.pdf (2.29. TRACE, 7.4.66. TRACE)"
# TRACE ?A – Example, 6

. after
- Using **TRACE ?A** for tracing all statements in interactive mode
    . after
    - Interactive tracing allows for inspecting, changing values, tracing step by step

. after group level=2
. after mark 1 pen=1
```rexx { .numberLines }
trace ?a     /* show all statements, enter interactive mode */
a=100+20
b=100+random(10,99)
say "a*b:" a*b
```

. end group

. click label level=2
Output:

. later id=#p8x17 numbered level=2
```output
       +++ "WindowsNT COMMAND E:\tmp\06_ooRexx\19_trace_r_interactive.rex"
     2 *-* a=100+20
+++ Interactive trace. "Trace Off" to end debug, ENTER to continue. +++
say a
120
a=100; trace r
    3 *-*     b=100+random(10,99)
       >>>       "198"
trace off
a*b: 19800
```

. click show #p8x17:1-3
. click show #p8x17:4

. click callout --> #p8x17:4 style="width:832px; max-width:none; box-sizing:border-box; font-size:19px" pin=top-left offset="311px 335px"
Execution stops, manually adding a statement to display the current value of variable **a**, \
pressing `<ENTER>`{.key} continues.

. click show #p8x17:5
. click show #p8x17:6

. click callout --> #p8x17:6 style="width:727px; max-width:none; box-sizing:border-box; font-size:19px" pin=top-left offset="418px 483px"
Execution stops, manually adding two statements: changing variable **a** to **100** and\
changing tracing to trace results from now on, pressing `<ENTER>`{.key}  continues.

. click show #p8x17:7
. click show #p8x17:8
. click show #p8x17:9

. click callout --> #p8x17:9 style="width:649px; max-width:none; box-sizing:border-box; font-size:19px" pin=top-left offset="496px 554px"
Execution stops, manually adding a single statement:\
set interactive tracing off, pressing `<ENTER>`{.key}  continues.

. click show #p8x17:10

<!-- slide # 9 (2026-10-15 09:37) ------------ business card (not in the ODP) -->
. slide card logo=none
# Contact