Trace (Debug)
Sometimes coding errors cannot be understood easily
Keyword statement TRACE and built-in function (BIF) TRACE()
Most important options
| 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 |
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
Output of run # 1:
a*b: 16800
Output of run # 2:
a*b: 17400
Output:
2 *-* a=100+20
3 *-* b=100+random(10,99)
4 *-* say "a*b:" a*b
a*b: 17040
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
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
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
Output:
Execution stops, manually adding a statement to display the current value of variable a,
pressing <ENTER> continues.
Execution stops, manually adding two statements: changing variable a to 100 and
changing tracing to trace results from now on, pressing <ENTER> continues.
Execution stops, manually adding a single statement:
set interactive tracing off, pressing <ENTER> continues.
WU
Prof. Mag. Dr. Rony G. Flatscher
Welthandelsplatz 1
1020 Wien/Vienna
Austria/Europe
www: www.wu.ac.at