Print debugging statement: Difference between revisions

Content added Content deleted
m (added whitespace before the table of contents (TOC).)
(→‎{{header|REXX}}: added the REXX computer programming language for this task.)
Line 196: Line 196:


9
9
</pre>

=={{header|REXX}}==
There are other options for the REXX's &nbsp; '''trace''' &nbsp; instruction, &nbsp; but the &nbsp; '''i''' &nbsp; is the most informative and
<br>shows intermediate results within a REXX statement as it's being evaluated.
<lang rexx>/*REXX program to demonstrate debugging (TRACE) information while executing a program*/
/*────────────────────────────────────────────── (below) the I is for information. */
trace i
parse arg maxDiv .
if maxDiv=='' | maxDiv=="," then maxDiv= 1000 /*obtain optional argument from the CL.*/
say 'maximum random divisor is:' maxDiv /*display the max divisor being used. */
total= 0
do j=1 to 100
total= total + j/random(maxDiv)
end /*j*/

say 'total=' total /*stick a fork in it, we're all done. */</lang>
{{out|output|text=&nbsp; when using the input of: &nbsp; &nbsp; <tt> 9 </tt>}}
<pre>
4 *-* parse arg maxDiv .
>>> "9"
>.> ""
5 *-* if maxDiv=='' | maxDiv=="," then maxDiv= 1000 /*obtain optional argument from the CL.*/
>V> "9"
>L> ","
>O> "0"
>V> "9"
>L> ""
>O> "0"
>U> "0"
6 *-* say 'maximum random divisor is:' maxDiv /*display the max divisor being used. */
>L> "maximum random divisor is:"
>V> "9"
>O> "maximum random divisor is: 9"
maximum random divisor is: 9
7 *-* total= 0
>L> "0"
8 *-* do j=1 to 100
>L> "1"
>L> "100"
>V> "1"
9 *-* total= total + j/random(maxDiv)
>V> "0"
>V> "1"
>V> "9"
>F> "8"
>O> "0.125"
>O> "0.125"
10 *-* end /*j*/
8 *-* do j=1 to 100
>V> "1"
>V> "2"
9 *-* total= total + j/random(maxDiv)
>V> "0.125"
>V> "2"
>V> "9"
>F> "6"
>O> "0.333333333"
>O> "0.458333333"
10 *-* end /*j*/
8 *-* do j=1 to 100
>V> "2"
>V> "3"
9 *-* total= total + j/random(maxDiv)
>V> "0.458333333"
>V> "3"
>V> "9"
>F> "0"
9 +++ total= total + j/random(maxDiv)
Error 42 running "c:\debuggin.rex", line 9: Arithmetic overflow/underflow
Error 42.3: Arithmetic overflow; divisor must not be zero
</pre>
</pre>