The current Debug_List routine

This code is in a file called "subroutines.rex" and is included from the main routine using ::Requires 'subroutines.rex'
It uses a couple of routines, "Systrace" and "Threads" which are not included here. "Systrace" just creates entries in a system-wide trace log. "Threads" works out the program being run under rexx in the parent thread. They are both highly specific to the system where the code is running.

::Routine Debug_List public
If .fatal.error = 1 then .local~debug.state = 1											/* Always debug fatal conditions		*/
If .debug[0] = 0 | .local~debug.state \== 1 then return										/* Debug_List: Anything to do?			*/
Arg parms															/* Get options: HTML LINES			*/
Parse arg ,efn															/* Get callers filename				*/
If efn = '' then do
  Call SysTrace 'Something called Debug_List without argument 2 (efn)',word('env'('Remote_User') 'env'('Remote_Addr'),1)	/* Blow whistle 				*/
  Call 'Threads' 'Debug_List()'													/* Try to work out how we got here		*/
  End
HTML	= wordpos('HTML',parms) > 0												/* Do we want the list in HTML?			*/
Lines	= wordpos('LINES',parms) > 0												/* Do we want line numbers?			*/
If html then say copies('</TABLE>',6)'hr'()'<H2 STYLE="border-width:0;padding:0;margin:0 0 0 0">Debug:</H2><TABLE CELLSPACING=0>'
Else say 'Debug:'
Trace = (.fatal.error = 1) & \'swifty'()											/* SysTrace any fatal error except Swifty's	*/
Do I = 1 to .debug[0]
  Select
    When html & lines then say '<TR VALIGN=TOP><TD ALIGN=RIGHT>'word(.debug[I],1)'<TD>'nohtml(subword(.debug[I],2))/* HTML output with line numbers		*/
    When html then say '<TR VALIGN=TOP><TD>'nohtml(.debug[I])								/* HTML output					*/
    Otherwise say .debug[I]													/* Plain text output				*/
    End
  If trace then call SysTrace .debug[I],efn
  End
If html then say '</TABLE>'
Return