MODULE clm$display_job_history_command;
?? RIGHT := 110 ??
?? NEWTITLE := '  CLM$DISPLAY_JOB_HISTORY_COMMAND' ??
?? PUSH (LISTEXT := ON) ??
*copyc clt$parameter_list
*copyc clt$keyword
*copyc fst$file_reference
*copyc jme$job_history_conditions
*copyc jmt$beginning_log_position
*copyc jmt$job_attribute_results
*copyc jmt$job_history_sorted_order
*copyc jmt$job_status_count
*copyc jmt$name
*copyc jmt$system_supplied_name
*copyc jmt$user_supplied_name
*copyc ost$name
*copyc ost$user_identification
?? POP ??
*copyc clp$count_list_elements
*copyc clp$evaluate_parameters
*copyc dfp$get_served_family_names
*copyc jmp$determine_name_kind
*copyc jmp$get_job_attributes
*copyc jmp$process_job_history
*copyc osp$set_status_abnormal
*copyc pmp$get_family_names
*copyc pmp$get_job_names
?? NEWTITLE := '[XDCL] clp$display_job_history_command', EJECT ??

  PROCEDURE [XDCL] clp$display_job_history_command
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);


{ PROCEDURE (osm$disjh) display_job_history (
{   job_name, jn: any of
{       key
{         current, all
{       keyend
{       list of name
{     anyend = current
{   login_family, family_name, fn, lf: any of
{       key
{         current, local, all
{       keyend
{       list of name
{     anyend = all
{   trace_job_children, tjc: boolean = false
{   trace_job_output, tjo: boolean = false
{   beginning_log_position, blp: key
{       (session, s)
{       (boi, b)
{       (today, t)
{     keyend = session
{   sorted_order, so: key
{       (time, t)
{       (job, j)
{       (family, f)
{     keyend = family
{   output, o: file = $output
{   input, i: (BY_NAME, HIDDEN) file = $optional
{   status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 19] of clt$pdt_parameter_name,
      parameters: array [1 .. 9] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
        type_size_1: clt$type_specification_size,
        element_type_spec_1: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 2] of clt$keyword_specification,
        recend,
        type_size_2: clt$type_specification_size,
        element_type_spec_2: record
          header: clt$type_specification_header,
          qualifier: clt$list_type_qualifier_v2,
          element_type_spec: record
            header: clt$type_specification_header,
            qualifier: clt$name_type_qualifier,
          recend,
        recend,
        default_value: string (7),
      recend,
      type2: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
        type_size_1: clt$type_specification_size,
        element_type_spec_1: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 3] of clt$keyword_specification,
        recend,
        type_size_2: clt$type_specification_size,
        element_type_spec_2: record
          header: clt$type_specification_header,
          qualifier: clt$list_type_qualifier_v2,
          element_type_spec: record
            header: clt$type_specification_header,
            qualifier: clt$name_type_qualifier,
          recend,
        recend,
        default_value: string (3),
      recend,
      type3: record
        header: clt$type_specification_header,
        default_value: string (5),
      recend,
      type4: record
        header: clt$type_specification_header,
        default_value: string (5),
      recend,
      type5: record
        header: clt$type_specification_header,
        qualifier: clt$keyword_type_qualifier,
        keyword_specs: array [1 .. 6] of clt$keyword_specification,
        default_value: string (7),
      recend,
      type6: record
        header: clt$type_specification_header,
        qualifier: clt$keyword_type_qualifier,
        keyword_specs: array [1 .. 6] of clt$keyword_specification,
        default_value: string (6),
      recend,
      type7: record
        header: clt$type_specification_header,
        default_value: string (7),
      recend,
      type8: record
        header: clt$type_specification_header,
      recend,
      type9: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [92, 8, 19, 17, 27, 28, 459],
    clc$command, 19, 9, 0, 0, 1, 0, 9, 'OSM$DISJH'], [
    ['BEGINNING_LOG_POSITION         ',clc$nominal_entry, 5],
    ['BLP                            ',clc$abbreviation_entry, 5],
    ['FAMILY_NAME                    ',clc$alias_entry, 2],
    ['FN                             ',clc$alias_entry, 2],
    ['I                              ',clc$abbreviation_entry, 8],
    ['INPUT                          ',clc$nominal_entry, 8],
    ['JN                             ',clc$abbreviation_entry, 1],
    ['JOB_NAME                       ',clc$nominal_entry, 1],
    ['LF                             ',clc$abbreviation_entry, 2],
    ['LOGIN_FAMILY                   ',clc$nominal_entry, 2],
    ['O                              ',clc$abbreviation_entry, 7],
    ['OUTPUT                         ',clc$nominal_entry, 7],
    ['SO                             ',clc$abbreviation_entry, 6],
    ['SORTED_ORDER                   ',clc$nominal_entry, 6],
    ['STATUS                         ',clc$nominal_entry, 9],
    ['TJC                            ',clc$abbreviation_entry, 3],
    ['TJO                            ',clc$abbreviation_entry, 4],
    ['TRACE_JOB_CHILDREN             ',clc$nominal_entry, 3],
    ['TRACE_JOB_OUTPUT               ',clc$nominal_entry, 4]],
    [
{ PARAMETER 1
    [8, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 122,
  clc$optional_default_parameter, 0, 7],
{ PARAMETER 2
    [10, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 159,
  clc$optional_default_parameter, 0, 3],
{ PARAMETER 3
    [18, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_default_parameter, 0, 5],
{ PARAMETER 4
    [19, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_default_parameter, 0, 5],
{ PARAMETER 5
    [1, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 229,
  clc$optional_default_parameter, 0, 7],
{ PARAMETER 6
    [14, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 229,
  clc$optional_default_parameter, 0, 6],
{ PARAMETER 7
    [12, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_default_parameter, 0, 7],
{ PARAMETER 8
    [6, clc$hidden_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$optional_parameter, 0
  , 0],
{ PARAMETER 9
    [15, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_parameter, 0, 0]],
{ PARAMETER 1
    [[1, 0, clc$union_type], [[clc$keyword_type, clc$list_type],
    FALSE, 2],
    81, [[1, 0, clc$keyword_type], [2], [
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 2],
      ['CURRENT                        ', clc$nominal_entry, clc$normal_usage_entry, 1]]
      ],
    21, [[1, 0, clc$list_type], [5, 1, clc$max_list_size, 0, FALSE, FALSE],
        [[1, 0, clc$name_type], [1, osc$max_name_size]]
      ]
    ,
    'current'],
{ PARAMETER 2
    [[1, 0, clc$union_type], [[clc$keyword_type, clc$list_type],
    FALSE, 2],
    118, [[1, 0, clc$keyword_type], [3], [
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 3],
      ['CURRENT                        ', clc$nominal_entry, clc$normal_usage_entry, 1],
      ['LOCAL                          ', clc$nominal_entry, clc$normal_usage_entry, 2]]
      ],
    21, [[1, 0, clc$list_type], [5, 1, clc$max_list_size, 0, FALSE, FALSE],
        [[1, 0, clc$name_type], [1, osc$max_name_size]]
      ]
    ,
    'all'],
{ PARAMETER 3
    [[1, 0, clc$boolean_type],
    'false'],
{ PARAMETER 4
    [[1, 0, clc$boolean_type],
    'false'],
{ PARAMETER 5
    [[1, 0, clc$keyword_type], [6], [
    ['B                              ', clc$abbreviation_entry, clc$normal_usage_entry, 2],
    ['BOI                            ', clc$nominal_entry, clc$normal_usage_entry, 2],
    ['S                              ', clc$abbreviation_entry, clc$normal_usage_entry, 1],
    ['SESSION                        ', clc$nominal_entry, clc$normal_usage_entry, 1],
    ['T                              ', clc$abbreviation_entry, clc$normal_usage_entry, 3],
    ['TODAY                          ', clc$nominal_entry, clc$normal_usage_entry, 3]]
    ,
    'session'],
{ PARAMETER 6
    [[1, 0, clc$keyword_type], [6], [
    ['F                              ', clc$abbreviation_entry, clc$normal_usage_entry, 3],
    ['FAMILY                         ', clc$nominal_entry, clc$normal_usage_entry, 3],
    ['J                              ', clc$abbreviation_entry, clc$normal_usage_entry, 2],
    ['JOB                            ', clc$nominal_entry, clc$normal_usage_entry, 2],
    ['T                              ', clc$abbreviation_entry, clc$normal_usage_entry, 1],
    ['TIME                           ', clc$nominal_entry, clc$normal_usage_entry, 1]]
    ,
    'family'],
{ PARAMETER 7
    [[1, 0, clc$file_type],
    '$output'],
{ PARAMETER 8
    [[1, 0, clc$file_type]],
{ PARAMETER 9
    [[1, 0, clc$status_type]]];

?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$job_name = 1,
      p$login_family = 2,
      p$trace_job_children = 3,
      p$trace_job_output = 4,
      p$beginning_log_position = 5,
      p$sorted_order = 6,
      p$output = 7,
      p$input = 8,
      p$status = 9;

    VAR
      pvt: array [1 .. 9] of clt$parameter_value;

?? POP ??

    VAR
      current_control_user: ost$user_identification,
      current_login_user: ost$user_identification,
      display_output_history_command: boolean,
      family_names_requested: ^pmt$family_name_list,
      foreign_count: integer,
      get_attribute_p: ^jmt$job_attribute_results,
      index: integer,
      input_file: ^fst$file_reference,
      job_name: jmt$name,
      job_names_requested: ^array [1 .. * ] of ost$name,
      local_families: ^pmt$family_name_list,
      name_count: pmt$family_name_count,
      name_list: ^clt$data_value,
      number_of_jobs_found: jmt$job_status_count,
      number_of_names: clt$list_size,
      output_file_name: ^fst$file_reference,
      output_files_requested: ^array [1 .. * ] of jmt$name,
      requested_sort_order: jmt$job_history_sorted_order,
      start_log_search: jmt$beginning_log_position,
      served_families: ^pmt$family_name_list,
      served_family_count: pmt$family_name_count,
      ssn: jmt$system_supplied_name,
      trace_all_jobs: boolean,
      trace_all_output: boolean,
      trace_job_children: boolean,
      trace_job_output: boolean,
      ujn: jmt$user_supplied_name;


    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

{ control user and login user

    PUSH get_attribute_p: [1 .. 4];
    get_attribute_p^ [1].key := jmc$control_user;
    get_attribute_p^ [2].key := jmc$control_family;
    get_attribute_p^ [3].key := jmc$login_user;
    get_attribute_p^ [4].key := jmc$login_family;
    jmp$get_job_attributes (get_attribute_p, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    trace_all_jobs := FALSE;
    current_control_user.user := get_attribute_p^ [1].control_user;
    current_control_user.family := get_attribute_p^ [2].control_family;
    current_login_user.user := get_attribute_p^ [3].login_user;
    current_login_user.family := get_attribute_p^ [4].login_family;

    IF ((pvt [p$job_name].value^.kind = clc$keyword) AND (pvt [p$job_name].value^.keyword_value = 'CURRENT'))
          THEN
      PUSH job_names_requested: [1 .. 1];
      pmp$get_job_names (ujn, ssn, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      job_names_requested^ [1] := ssn;
    ELSEIF ((pvt [p$job_name].value^.kind = clc$keyword) AND (pvt [p$job_name].value^.keyword_value = 'ALL'))
          THEN
      trace_all_jobs := TRUE;
      job_names_requested := NIL;
    ELSE
      number_of_names := clp$count_list_elements (pvt [p$job_name].value);
      PUSH job_names_requested: [1 .. number_of_names];
      name_list := pvt [p$job_name].value;
      FOR index := 1 TO number_of_names DO
        jmp$determine_name_kind (name_list^.element_value^.name_value, job_name, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        IF job_name.kind = jmc$system_supplied_name THEN
          job_names_requested^ [index] := job_name.system_supplied_name;
        ELSE {user supplied name}
          job_names_requested^ [index] := job_name.user_supplied_name;
        IFEND;
        name_list := name_list^.link;
      FOREND;
    IFEND;


    IF (pvt [p$sorted_order].value^.keyword_value = 'TIME') THEN
      requested_sort_order := jmc$sort_by_time;
    ELSEIF (pvt [p$sorted_order].value^.keyword_value = 'JOB') THEN
      requested_sort_order := jmc$sort_by_job;
    ELSE
      requested_sort_order := jmc$sort_by_family;
    IFEND;

{ Processing family name value

    foreign_count := 0;
    IF (pvt [p$login_family].value^.kind = clc$keyword) THEN
      IF (pvt [p$login_family].value^.keyword_value = 'CURRENT') THEN
        PUSH family_names_requested: [1 .. 1];
        family_names_requested^ [1] := current_login_user.family;
      ELSE
        name_count := 10; { arbitrary constant greater (?) than the number of families }

{ on the system

        IF (pvt [p$login_family].value^.keyword_value = 'ALL') THEN
          foreign_count := 1;
        IFEND;

      /get_local_family_list/
        REPEAT

          PUSH family_names_requested: [1 .. (name_count + foreign_count)];
          pmp$get_family_names (family_names_requested^, name_count, status);
          IF NOT status.normal THEN
            IF status.condition = pme$result_array_too_small THEN
              CYCLE /get_local_family_list/;

{ if the number of families exceeds the value in name_count (10) we will retry the
{ interface pmp$get_family_names using the new value in name_count that was returned

            IFEND;
            RETURN;
          IFEND;
        UNTIL status.normal;
        IF (foreign_count = 1) THEN
          name_count := name_count + 1;
          family_names_requested^ [name_count] := osc$null_name;
        IFEND;

        served_family_count := 5;

      /get_served_family_list/
        REPEAT
          PUSH served_families: [1 .. served_family_count];
          dfp$get_served_family_names (served_families^, served_family_count, status);
          IF NOT status.normal THEN
            IF status.condition = pme$result_array_too_small THEN
              CYCLE /get_served_family_list/;

{ if the number of families exceeds the value in served_family_count (5) we will retry the
{ interface dfp$get_served_family_names using the new value in served_family_count that was returned

            IFEND;
            RETURN;
          IFEND;
        UNTIL status.normal;

        IF served_family_count = 0 THEN

{ We have all of the families.

        ELSEIF (served_family_count + name_count) <= UPPERBOUND (family_names_requested^) THEN
          FOR index := (name_count + 1) TO (name_count + served_family_count) DO
            family_names_requested^ [index] := served_families^ [index - name_count];
          FOREND;
        ELSE
          local_families := family_names_requested;
          PUSH family_names_requested: [1 .. (name_count + served_family_count)];
          FOR index := 1 TO name_count DO
            family_names_requested^ [index] := local_families^ [index];
          FOREND;
          FOR index := (name_count + 1) TO (name_count + served_family_count) DO
            family_names_requested^ [index] := served_families^ [index - name_count];
          FOREND;
        IFEND;
      IFEND;
    ELSE
      name_list := pvt [p$login_family].value;
      number_of_names := clp$count_list_elements (pvt [p$login_family].value);
      PUSH family_names_requested: [1 .. number_of_names];
      family_names_requested^ [1] := name_list^.element_value^.name_value;
      index := 2;
      WHILE index <= number_of_names DO
        name_list := name_list^.link;
        family_names_requested^ [index] := name_list^.element_value^.name_value;
        index := index + 1;
      WHILEND;
    IFEND;

{ PROCESSING BEGINNING_LOG_POSITION PARAMETER

    IF (pvt [p$beginning_log_position].value^.keyword_value = 'TODAY') THEN
      start_log_search := jmc$today;
    ELSEIF (pvt [p$beginning_log_position].value^.keyword_value = 'BOI') THEN
      start_log_search := jmc$boi;
    ELSE
      start_log_search := jmc$session;
    IFEND;

{ PROCESSING  OUTPUT PARAMETER

    output_file_name := pvt [p$output].value^.file_value;

{ Process TRACE JOB CHILDREN parameter.

    trace_job_children := pvt [p$trace_job_children].value^.boolean_value.value;

{ Process TRACE JOB OUTPUT parameter.

    trace_job_output := pvt [p$trace_job_output].value^.boolean_value.value;

{ Process INPUT parameter

    IF pvt [p$input].specified THEN
      input_file := pvt [p$input].value^.file_value;
    ELSE;
      input_file := NIL;
    IFEND;
    display_output_history_command := FALSE;
    trace_all_output := (trace_all_jobs AND trace_job_output);
    output_files_requested := NIL;


    jmp$process_job_history (current_control_user, current_login_user, requested_sort_order,
          trace_job_children, trace_job_output, trace_all_jobs, trace_all_output,
          display_output_history_command, job_names_requested, family_names_requested, output_files_requested,
          start_log_search, output_file_name, input_file, status);

  PROCEND clp$display_job_history_command;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] clp$display_output_history_cmd', EJECT ??

  PROCEDURE [XDCL] clp$display_output_history_cmd
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{
{ PROCEDURE (osm$disoh) display_output_history_pdt (
{   output_file_name, ofn: any of
{       key
{         all
{       keyend
{       list of name
{     anyend = all
{   job_name, jn: any of
{       key
{         current, all
{       keyend
{       list of name
{     anyend = current
{   login_family, family_name, fn, lf: any of
{       key
{         current, local, all
{       keyend
{       list of name
{     anyend = all
{   beginning_log_position, blp: key
{       (session, s)
{       (boi, b)
{       (today, t)
{     keyend = session
{   sorted_order, so: key
{       (time, t)
{       (job, j)
{       (family, f)
{     keyend = family
{   output, o: file = $output
{   input, i: (BY_NAME, HIDDEN) file = $optional
{   status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 17] of clt$pdt_parameter_name,
      parameters: array [1 .. 8] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
        type_size_1: clt$type_specification_size,
        element_type_spec_1: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 1] of clt$keyword_specification,
        recend,
        type_size_2: clt$type_specification_size,
        element_type_spec_2: record
          header: clt$type_specification_header,
          qualifier: clt$list_type_qualifier_v2,
          element_type_spec: record
            header: clt$type_specification_header,
            qualifier: clt$name_type_qualifier,
          recend,
        recend,
        default_value: string (3),
      recend,
      type2: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
        type_size_1: clt$type_specification_size,
        element_type_spec_1: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 2] of clt$keyword_specification,
        recend,
        type_size_2: clt$type_specification_size,
        element_type_spec_2: record
          header: clt$type_specification_header,
          qualifier: clt$list_type_qualifier_v2,
          element_type_spec: record
            header: clt$type_specification_header,
            qualifier: clt$name_type_qualifier,
          recend,
        recend,
        default_value: string (7),
      recend,
      type3: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
        type_size_1: clt$type_specification_size,
        element_type_spec_1: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 3] of clt$keyword_specification,
        recend,
        type_size_2: clt$type_specification_size,
        element_type_spec_2: record
          header: clt$type_specification_header,
          qualifier: clt$list_type_qualifier_v2,
          element_type_spec: record
            header: clt$type_specification_header,
            qualifier: clt$name_type_qualifier,
          recend,
        recend,
        default_value: string (3),
      recend,
      type4: record
        header: clt$type_specification_header,
        qualifier: clt$keyword_type_qualifier,
        keyword_specs: array [1 .. 6] of clt$keyword_specification,
        default_value: string (7),
      recend,
      type5: record
        header: clt$type_specification_header,
        qualifier: clt$keyword_type_qualifier,
        keyword_specs: array [1 .. 6] of clt$keyword_specification,
        default_value: string (6),
      recend,
      type6: record
        header: clt$type_specification_header,
        default_value: string (7),
      recend,
      type7: record
        header: clt$type_specification_header,
      recend,
      type8: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [92, 8, 26, 13, 55, 46, 848],
    clc$command, 17, 8, 0, 0, 1, 0, 8, 'OSM$DISOH'], [
    ['BEGINNING_LOG_POSITION         ',clc$nominal_entry, 4],
    ['BLP                            ',clc$abbreviation_entry, 4],
    ['FAMILY_NAME                    ',clc$alias_entry, 3],
    ['FN                             ',clc$alias_entry, 3],
    ['I                              ',clc$abbreviation_entry, 7],
    ['INPUT                          ',clc$nominal_entry, 7],
    ['JN                             ',clc$abbreviation_entry, 2],
    ['JOB_NAME                       ',clc$nominal_entry, 2],
    ['LF                             ',clc$abbreviation_entry, 3],
    ['LOGIN_FAMILY                   ',clc$nominal_entry, 3],
    ['O                              ',clc$abbreviation_entry, 6],
    ['OFN                            ',clc$abbreviation_entry, 1],
    ['OUTPUT                         ',clc$nominal_entry, 6],
    ['OUTPUT_FILE_NAME               ',clc$nominal_entry, 1],
    ['SO                             ',clc$abbreviation_entry, 5],
    ['SORTED_ORDER                   ',clc$nominal_entry, 5],
    ['STATUS                         ',clc$nominal_entry, 8]],
    [
{ PARAMETER 1
    [14, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 85,
  clc$optional_default_parameter, 0, 3],
{ PARAMETER 2
    [8, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 122,
  clc$optional_default_parameter, 0, 7],
{ PARAMETER 3
    [10, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 159,
  clc$optional_default_parameter, 0, 3],
{ PARAMETER 4
    [1, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 229,
  clc$optional_default_parameter, 0, 7],
{ PARAMETER 5
    [16, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 229,
  clc$optional_default_parameter, 0, 6],
{ PARAMETER 6
    [13, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_default_parameter, 0, 7],
{ PARAMETER 7
    [6, clc$hidden_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$optional_parameter, 0
  , 0],
{ PARAMETER 8
    [17, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_parameter, 0, 0]],
{ PARAMETER 1
    [[1, 0, clc$union_type], [[clc$keyword_type, clc$list_type],
    FALSE, 2],
    44, [[1, 0, clc$keyword_type], [1], [
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 1]]
      ],
    21, [[1, 0, clc$list_type], [5, 1, clc$max_list_size, 0, FALSE, FALSE],
        [[1, 0, clc$name_type], [1, osc$max_name_size]]
      ]
    ,
    'all'],
{ PARAMETER 2
    [[1, 0, clc$union_type], [[clc$keyword_type, clc$list_type],
    FALSE, 2],
    81, [[1, 0, clc$keyword_type], [2], [
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 2],
      ['CURRENT                        ', clc$nominal_entry, clc$normal_usage_entry, 1]]
      ],
    21, [[1, 0, clc$list_type], [5, 1, clc$max_list_size, 0, FALSE, FALSE],
        [[1, 0, clc$name_type], [1, osc$max_name_size]]
      ]
    ,
    'current'],
{ PARAMETER 3
    [[1, 0, clc$union_type], [[clc$keyword_type, clc$list_type],
    FALSE, 2],
    118, [[1, 0, clc$keyword_type], [3], [
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 3],
      ['CURRENT                        ', clc$nominal_entry, clc$normal_usage_entry, 1],
      ['LOCAL                          ', clc$nominal_entry, clc$normal_usage_entry, 2]]
      ],
    21, [[1, 0, clc$list_type], [5, 1, clc$max_list_size, 0, FALSE, FALSE],
        [[1, 0, clc$name_type], [1, osc$max_name_size]]
      ]
    ,
    'all'],
{ PARAMETER 4
    [[1, 0, clc$keyword_type], [6], [
    ['B                              ', clc$abbreviation_entry, clc$normal_usage_entry, 2],
    ['BOI                            ', clc$nominal_entry, clc$normal_usage_entry, 2],
    ['S                              ', clc$abbreviation_entry, clc$normal_usage_entry, 1],
    ['SESSION                        ', clc$nominal_entry, clc$normal_usage_entry, 1],
    ['T                              ', clc$abbreviation_entry, clc$normal_usage_entry, 3],
    ['TODAY                          ', clc$nominal_entry, clc$normal_usage_entry, 3]]
    ,
    'session'],
{ PARAMETER 5
    [[1, 0, clc$keyword_type], [6], [
    ['F                              ', clc$abbreviation_entry, clc$normal_usage_entry, 3],
    ['FAMILY                         ', clc$nominal_entry, clc$normal_usage_entry, 3],
    ['J                              ', clc$abbreviation_entry, clc$normal_usage_entry, 2],
    ['JOB                            ', clc$nominal_entry, clc$normal_usage_entry, 2],
    ['T                              ', clc$abbreviation_entry, clc$normal_usage_entry, 1],
    ['TIME                           ', clc$nominal_entry, clc$normal_usage_entry, 1]]
    ,
    'family'],
{ PARAMETER 6
    [[1, 0, clc$file_type],
    '$output'],
{ PARAMETER 7
    [[1, 0, clc$file_type]],
{ PARAMETER 8
    [[1, 0, clc$status_type]]];

?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$output_file_name = 1,
      p$job_name = 2,
      p$login_family = 3,
      p$beginning_log_position = 4,
      p$sorted_order = 5,
      p$output = 6,
      p$input = 7,
      p$status = 8;

    VAR
      pvt: array [1 .. 8] of clt$parameter_value;

    VAR
      current_control_user: ost$user_identification,
      current_login_user: ost$user_identification,
      display_output_history_command: boolean,
      family_names_requested: ^pmt$family_name_list,
      foreign_count: integer,
      get_attribute_p: ^jmt$job_attribute_results,
      index: integer,
      input_file: ^fst$file_reference,
      job_name: jmt$name,
      job_names_requested: ^array [1 .. * ] of ost$name,
      local_families: ^pmt$family_name_list,
      name_count: pmt$family_name_count,
      name_list: ^clt$data_value,
      number_of_jobs_found: jmt$job_status_count,
      number_of_names: clt$list_size,
      output_file_name: ^fst$file_reference,
      output_files_requested: ^array [1 .. * ] of jmt$name,
      requested_sort_order: jmt$job_history_sorted_order,
      start_log_search: jmt$beginning_log_position,
      served_families: ^pmt$family_name_list,
      served_family_count: pmt$family_name_count,
      ssn: jmt$system_supplied_name,
      trace_all_jobs: boolean,
      trace_all_output: boolean,
      trace_job_children: boolean,
      trace_job_output: boolean,
      ujn: jmt$user_supplied_name;


    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

{ get control user and login user

    PUSH get_attribute_p: [1 .. 4];
    get_attribute_p^ [1].key := jmc$control_user;
    get_attribute_p^ [2].key := jmc$control_family;
    get_attribute_p^ [3].key := jmc$login_user;
    get_attribute_p^ [4].key := jmc$login_family;
    jmp$get_job_attributes (get_attribute_p, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    trace_all_jobs := FALSE;
    current_control_user.user := get_attribute_p^ [1].control_user;
    current_control_user.family := get_attribute_p^ [2].control_family;
    current_login_user.user := get_attribute_p^ [3].login_user;
    current_login_user.family := get_attribute_p^ [4].login_family;


    IF ((pvt [p$job_name].value^.kind = clc$keyword) AND (pvt [p$job_name].value^.keyword_value = 'CURRENT'))
          THEN
      PUSH job_names_requested: [1 .. 1];
      pmp$get_job_names (ujn, ssn, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      job_names_requested^ [1] := ssn;
    ELSEIF ((pvt [p$job_name].value^.kind = clc$keyword) AND (pvt [p$job_name].value^.keyword_value = 'ALL'))
          THEN
      trace_all_jobs := TRUE;
      job_names_requested := NIL;
    ELSE
      number_of_names := clp$count_list_elements (pvt [p$job_name].value);
      PUSH job_names_requested: [1 .. number_of_names];
      name_list := pvt [p$job_name].value;
      FOR index := 1 TO number_of_names DO
        jmp$determine_name_kind (name_list^.element_value^.name_value, job_name, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        IF job_name.kind = jmc$system_supplied_name THEN
          job_names_requested^ [index] := job_name.system_supplied_name;
        ELSE {user supplied name}
          job_names_requested^ [index] := job_name.user_supplied_name;
        IFEND;
        name_list := name_list^.link;
      FOREND;
    IFEND;


    IF (pvt [p$sorted_order].value^.keyword_value = 'TIME') THEN
      requested_sort_order := jmc$sort_by_time;
    ELSEIF (pvt [p$sorted_order].value^.keyword_value = 'JOB') THEN
      requested_sort_order := jmc$sort_by_job;
    ELSE
      requested_sort_order := jmc$sort_by_family;
    IFEND;

{ If Family name is keyword ALL then the following code is required.
{  Processing family name value

    foreign_count := 0;
    IF (pvt [p$login_family].value^.kind = clc$keyword) THEN
      IF (pvt [p$login_family].value^.keyword_value = 'CURRENT') THEN
        PUSH family_names_requested: [1 .. 1];
        family_names_requested^ [1] := current_login_user.family;
      ELSE
        name_count := 10; { arbitrary constant greater (?) than the number of families }

{ on the system

        IF (pvt [p$login_family].value^.keyword_value = 'ALL') THEN
          foreign_count := 1;
        IFEND;

      /get_local_family_list/
        REPEAT

          PUSH family_names_requested: [1 .. (name_count + foreign_count)];
          pmp$get_family_names (family_names_requested^, name_count, status);
          IF NOT status.normal THEN
            IF status.condition = pme$result_array_too_small THEN
              CYCLE /get_local_family_list/;

{ if the number of families exceeds the value in name_count (10) we will retry the
{ interface pmp$get_family_names using the new value in name_count that was returned

            IFEND;
            RETURN;
          IFEND;
        UNTIL status.normal;
        IF (foreign_count = 1) THEN
          name_count := name_count + 1;
          family_names_requested^ [name_count] := osc$null_name;
        IFEND;

        served_family_count := 5;

      /get_served_family_list/
        REPEAT
          PUSH served_families: [1 .. served_family_count];
          dfp$get_served_family_names (served_families^, served_family_count, status);
          IF NOT status.normal THEN
            IF status.condition = pme$result_array_too_small THEN
              CYCLE /get_served_family_list/;

{ if the number of families exceeds the value in served_family_count (5) we will retry the
{ interface dfp$get_served_family_names using the new value in served_family_count that was returned

            IFEND;
            RETURN;
          IFEND;
        UNTIL status.normal;

        IF served_family_count = 0 THEN

{ We have all of the families.

        ELSEIF (served_family_count + name_count) <= UPPERBOUND (family_names_requested^) THEN
          FOR index := (name_count + 1) TO (name_count + served_family_count) DO
            family_names_requested^ [index] := served_families^ [index - name_count];
          FOREND;
        ELSE
          local_families := family_names_requested;
          PUSH family_names_requested: [1 .. (name_count + served_family_count)];
          FOR index := 1 TO name_count DO
            family_names_requested^ [index] := local_families^ [index];
          FOREND;
          FOR index := (name_count + 1) TO (name_count + served_family_count) DO
            family_names_requested^ [index] := served_families^ [index - name_count];
          FOREND;
        IFEND;
      IFEND;
    ELSE
      name_list := pvt [p$login_family].value;
      number_of_names := clp$count_list_elements (pvt [p$login_family].value);
      PUSH family_names_requested: [1 .. number_of_names];
      family_names_requested^ [1] := name_list^.element_value^.name_value;
      index := 2;
      WHILE index <= number_of_names DO
        name_list := name_list^.link;
        family_names_requested^ [index] := name_list^.element_value^.name_value;
        index := index + 1;
      WHILEND;
    IFEND;

{ PROCESSING BEGINNING_LOG_POSITION PARAMETER

    IF (pvt [p$beginning_log_position].value^.keyword_value = 'TODAY') THEN
      start_log_search := jmc$today;
    ELSEIF (pvt [p$beginning_log_position].value^.keyword_value = 'BOI') THEN
      start_log_search := jmc$boi;
    ELSE
      start_log_search := jmc$session;
    IFEND;

{ PROCESSING  OUTPUT PARAMETER

    output_file_name := pvt [p$output].value^.file_value;

    trace_job_children := FALSE;

{ Process INPUT parameter

    IF pvt [p$input].specified THEN
      input_file := pvt [p$input].value^.file_value;
    ELSE;
      input_file := NIL;
    IFEND;

{ Processing Output parameter value

    IF ((pvt [p$output_file_name].value^.kind = clc$keyword) AND
          (pvt [p$output_file_name].value^.keyword_value = 'ALL')) THEN
      trace_all_output := TRUE;
    ELSE
      number_of_names := clp$count_list_elements (pvt [p$output_file_name].value);
      name_list := pvt [p$output_file_name].value;
      trace_all_output := FALSE;
      PUSH output_files_requested: [1 .. number_of_names];
      FOR index := 1 TO number_of_names DO
        jmp$determine_name_kind (name_list^.element_value^.name_value, job_name, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        output_files_requested^ [index] := job_name;
        name_list := name_list^.link;
      FOREND;
    IFEND;

    trace_job_output := TRUE;
    display_output_history_command := TRUE;

    jmp$process_job_history (current_control_user, current_login_user, requested_sort_order,
          trace_job_children, trace_job_output, trace_all_jobs, trace_all_output,
          display_output_history_command, job_names_requested, family_names_requested, output_files_requested,
          start_log_search, output_file_name, input_file, status);

  PROCEND clp$display_output_history_cmd;

MODEND clm$display_job_history_command;
