![[Toc]](../../toc.gif)
![[Index]](/idx.gif)
Debug: Print information about a procedure
This is a simple routine to print some information about a function. This
routine uses only dynamically retrieved information so there is no need to
change anything if defining a new routine.
This is especially useful for debugging.
Note that this routine will NOT work in "compiled" REXX programs because
of the missing source code. It's only ment for debugging your REXX
programs.
Sample Output:
[+++DEBUG+++] Inside "RoutineA" (Line 12)
[+++DEBUG+++] Called from line 3.
This is RoutineA
[+++DEBUG+++] Inside "RoutineB" (Line 20)
[+++DEBUG+++] Called from line 16.
This is RoutineB
[+++DEBUG+++] Inside "RoutineC" (Line 25)
[+++DEBUG+++] Called from line 17.
This is RoutineC
[+++DEBUG+++] Inside "RoutineB" (Line 20)
[+++DEBUG+++] Called from line 29.
This is RoutineB
[+++DEBUG+++] Inside "RoutineB" (Line 20)
[+++DEBUG+++] Called from line 4.
This is RoutineB
[+++DEBUG+++] Inside "RoutineC" (Line 25)
[+++DEBUG+++] Called from line 5.
This is RoutineC
[+++DEBUG+++] Inside "RoutineB" (Line 20)
[+++DEBUG+++] Called from line 29.
This is RoutineB
[+++DEBUG+++] Inside "RoutineD" (Line 32)
[+++DEBUG+++] Called from line 6.
This is RoutineD
[+++DEBUG+++] Inside "RoutineA" (Line 12)
[+++DEBUG+++] Called from line 36.
This is RoutineA
[+++DEBUG+++] Inside "RoutineB" (Line 20)
[+++DEBUG+++] Called from line 16.
This is RoutineB
[+++DEBUG+++] Inside "RoutineC" (Line 25)
[+++DEBUG+++] Called from line 17.
This is RoutineC
[+++DEBUG+++] Inside "RoutineB" (Line 20)
[+++DEBUG+++] Called from line 29.
This is RoutineB
[+++DEBUG+++] Inside "RoutineC" (Line 25)
[+++DEBUG+++] Called from line 37.
This is RoutineC
[+++DEBUG+++] Inside "RoutineB" (Line 20)
[+++DEBUG+++] Called from line 29.
This is RoutineB
/* ------------------------------------------------------------------ */
/* simple debugging routine to print data of the called procedure */
call RoutineA
call RoutineB
call RoutineC
call RoutineD
exit
/* ------------------------- sub routines --------------------------- */
RoutineA:
call GetRoutineStatistics sigl
say 'This is RoutineA'
call RoutineB
call RoutineC
return
RoutineB: PROCEDURE expose sigl
call GetRoutineStatistics sigl
say 'This is RoutineB'
return
RoutineC: PROCEDURE expose sigl
call GetRoutineStatistics sigl
say 'This is RoutineC'
call RoutineB
return
RoutineD: PROCEDURE expose sigl
call GetRoutineStatistics sigl
say 'This is RoutineD'
call RoutineA
call RoutineC
return
/* ------------------------------------------------------------------ */
/*-function: Get and print debugging information */
/* */
/*-call: call GetRoutineStatistics sigl {,donotprint} */
/* */
/* where: sigl - the variable sigl */
/* donotprint - if this parameter exists with any value */
/* there's nothing written to STDOUT */
/*-returns: 0 */
/* */
/*-notes: It is important that this procedure is called in the */
/* *FIRST* line after the procedure definition! */
/* It's also mandatory that the procedure MUST expose */
/* the variable SIGL if it is defined with the keyword */
/* PROCEDURE! */
/* */
/* example Usage: */
/* */
/* MySubRoutine: */
/* call GetRoutineStatistics sigl */
/* */
/* or */
/* MySubRoutine: PROCEDURE expose sigl */
/* call GetRoutineStatistics sigl */
/* */
GetRoutineStatistics: PROCEDURE expose sigl
parse arg debug.__lineCalledFrom
debug.__FirstLineOfRoutine = sigl-1
parse value sourceLine( sigl-1 ) with debug.__thisRoutine ':' .
if arg( 2, 'o' ) = 1 then
do
call LineOut, '[+++DEBUG+++] ' || 'Inside "' || debug.__thisRoutine || '" (Line ' || debug.__FirstLineOfRoutine || ')'
call LineOut, '[+++DEBUG+++] ' || ' Called from line ' || debug.__lineCalledFrom || '.'
end
return
Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs