PROCEDURE dum$display_task_environment display_task_environment, diste (
  output, o: file = $output
  status)

  VAR
    gtid: integer
    gtid_length: integer
    gtid_offset: integer
    link_length: integer
    link_offset: integer
    local_status: status
    output_file: file
    save_length: integer
    save_offset: integer
    xcb_p: 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_TASK_ENVIRONMENT' o=output_file
  put_line l=' ' o=output_file

  xcb_p = $memory($symbol_address(job_xcb_list), 6)

  fetch_field_info t=ost$execution_control_block f=GLOBAL_TASK_ID o=gtid_offset l=gtid_length
  fetch_field_info t=ost$execution_control_block f=LINK o=link_offset l=link_length
  fetch_field_info t=ost$execution_control_block f=SAVE9 o=save_offset l=save_length

  link_offset = link_offset / 8
  link_length = link_length / 8
  gtid_offset = gtid_offset / 8
  gtid_length = gtid_length / 8
  save_offset = save_offset / 8
  save_length = save_length / 8

  WHILE NOT $nil_pva(xcb_p) DO
    gtid = $memory(xcb_p+gtid_offset, gtid_length)
    line =' Address: '//$strrep(xcb_p, 16)//' Gtid: '//$strrep(gtid, 16)
    line = line//' Name: '//$ms(xcb_p+save_offset, save_length)
    put_line l=line o=output_file
    xcb_p = $memory(xcb_p+link_offset, link_length)
  WHILEND

PROCEND dum$display_task_environment
