Debugging Example
The example below sets a breakpoint right before the Compute procedure of the RightTriangle routine (from the beginning of this tutorial). The “L+” will cause a break before every line of the routine, even within the called Compute procedure.
SAMPLES>zbreak RightTriangle+20^RightTriangle:"L+"
SAMPLES>d ^RightTriangle
Compute the area and hypotenuse of a right triangle
given the lengths of its two sides.
First, choose a unit of measurement.
(i)nches, (f)eet, (m)iles, (c)entimeters, m(e)ters, (k)ilometers: f
Length of side 1: 4 Accepted.
Length of side 2: 5 Accepted.
quit:(side2 = "") // exit the routine
^
<BREAK>RightTriangle+21^RightTriangle
SAMPLES 2d0>g ; continue execution
do Compute( units, side1, side2)
^
<BREAK>RightTriangle+22^RightTriangle
SAMPLES 2d0>write side2
5
SAMPLES 2d0>g
{ set area = ( A * B ) / 2,
^
area = $justify( area, 0, 2),
squaredSides = ( A ** 2 ) + ( B ** 2 )
<BREAK>IsNegative+11^RightTriangle
SAMPLES 3d1>write B
5
SAMPLES 3d1>g
set hypot = $zsqr(squaredSides)
^
<BREAK>IsNegative+14^RightTriangle
SAMPLES 3d1>g
set hypot = $justify( hypot, 0, 2) // round hypot to 2 places
^
<BREAK>IsNegative+15^RightTriangle
SAMPLES 3d1>write hypot
6.403124237432848685
SAMPLES 3d1>b "C" ; cancel the stepping within Compute
SAMPLES 3d1>g
The area of this triangle is 10.00 square feet.
The hypotenuse is 6.40 feet.
write !!, "Current date: "
^
<BREAK>RightTriangle+23^RightTriangle
SAMPLES 2d0>b "L" ; don't step into %D or %T
SAMPLES 2d0>g
Current date:
do ^%D
^
<BREAK>RightTriangle+24^RightTriangle
SAMPLES 2d0>g
Feb 25 2011
write !, "Current time:"
^
<BREAK>RightTriangle+25^RightTriangle
SAMPLES 2d0>g
Current time:
do ^%T
^
<BREAK>RightTriangle+26^RightTriangle
SAMPLES 2d0>g
6:10 PM
quit
^
<BREAK>RightTriangle+27^RightTriangle
SAMPLES 2d0>g
SAMPLES>