PROCEDURE dum$display_active_tasks, display_active_tasks, disat (
  output, o: file = $output
  status)

  VAR
    jmv$jcb: integer = 300000000(16)              "($sa(jmv$jcb))
    job_monitor_xcb_offset: integer = 100(16)     "from start of job fixed
    syc$rc_maximum_value: integer = 86            "see deck syc$monitor_request_codes
  VAREND

  VAR
    field_length: integer
    field_offset: integer
    function: integer
    job_monitor_xcb: integer
    line: string
    link: integer
    local_file: file = $fname('$local.'//$unique)
    local_status: status
    mcr: integer
    monitor_functions: ARRAY 0 .. syc$rc_maximum_value OF string
    output_file: file
    task_name: integer
    task_number: integer
    task_xcb: integer
  VAREND

  IF $file(output open_position) = '$BOI' THEN
    delete_file f=output status=local_status
    set_file_attributes f=output fc=list
  IFEND
  output_file = output.$eoi

  put_line l='1COMMAND: DISPLAY_ACTIVE_TASKS' o=output_file
  put_line l=' ' o=output_file

  task_xcb = $memory($symbol_address(job_xcb_list))
  job_monitor_xcb = $rma(jmv$jcb+job_monitor_xcb_offset)

  ost$execution_control_block field=SAVE9 offset=field_offset length=field_length
  task_name = field_offset/8                  "offset into the XCB
  ost$execution_control_block field=LINK offset=field_offset length=field_length
  link = field_offset/8                       "offset into xcb

  create_monitor_func_file f=local_file
  accept_line v=monitor_functions i=local_file
  detach_file f=local_file

  task_number = 0
  process_tasks: ..
  REPEAT
    line = ' '//$strrep(task_number)//'.'
    change_processor_register jps=$rma(task_xcb)
    line = line//' task name = '//$trim($memory_string((task_xcb+task_name) 31))
    mcr = $process_register(mcr) / 20(16)
    IF mcr <> ((mcr / 2) * 2) THEN
      function = $memory(task_xcb+088(16) 1)
      IF (function > 0) AND (function <= syc$rc_maximum_value) THEN
        line = line//', monitor request = '//monitor_functions(function)
      IFEND
    IFEND
    line = line//', jps = '//$strrep($rma(task_xcb) 16)//'(16)'
    put_line l=line o=output_file
    EXIT process_tasks WHEN $rma(task_xcb) = job_monitor_xcb
    task_xcb = $memory(task_xcb+link)
    task_number = task_number + 1
  UNTIL $nil_pva(task_xcb)

PROCEND dum$display_active_tasks
