PROC dum$display_attached_pf_table, display_attached_pf_table, disapft (
  p_attached_pf_table, address: integer 0 .. $max_integer
  array_size, as: integer 0 .. $max_integer
  element_size, es: integer 0 .. $max_integer
  output, o : file = $output
  status    : var of status = $optional
  )

" This procedure displays all permanent files attached within
" the job.  The table defaults to the attached pf table of the current job,
" but the parameters are required for use by the file server procccdures.
" The correct job must be selected prior to using this PROC.
" When attempting to display the attached file for files attached on the server,
" the correct clone task may be selected, and must
"   be processing for this job, (alternately use display_client_mainframe file.

  crev local_status status

  IF $file($value(output) open_position) = '$BOI' THEN
    rewind_file $value(output) status=local_status
  IFEND
  output_file = $string($value(output)) // '.$eoi'

  IF $specified(p_attached_pf_table) THEN
    pfv$p_attached_pf_table = $value(p_attached_pf_table)
    lower_bound = 1
    array_size = $value(array_size)
    element_size =  $value(element_size)
  ELSE " Default to what the current task is using
    pfv$p_attached_pf_table = $mem($sa(pfv$p_p_attached_pf_table))
    array_size = $mem(pfv$p_attached_pf_table+6, 4)
    lower_bound = $mem(pfv$p_attached_pf_table+10, 4)
    element_size = $mem(pfv$p_attached_pf_table+14, 4)
    pfv$p_attached_pf_table = $mem($mem($sa(pfv$p_p_attached_pf_table)))
  IFEND
  upper_bound = lower_bound + (array_size / element_size) - 1

  putl ' pfv$p_attached_pf_table '//$strrep(pfv$p_attached_pf_table, 16)//'(16)' o=$fname(output_file)
  putl ' lower_bound '//$strrep(lower_bound)//' upper_bound '//$strrep(upper_bound)  o=$fname(output_file)
  FOR apfid = lower_bound TO upper_bound DO
    putl ' ------------ apfid '//$strrep(apfid) o=$fname(output_file)
    display_apft_entry pfv$p_attached_pf_table+((apfid-lower_bound)*element_size) o=$fname(output_file) ..
          status=local_status
    IF NOT local_status.normal THEN
      disv local_status o=$fname(output_file)
    IFEND
  FOREND

PROCEND dum$display_attached_pf_table
