?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE SCL Interpreter: Display Value Command' ??
MODULE clm$display_value_command;

{
{ PURPOSE:
{   This module contains the processor for the display_value command.
{

?? NEWTITLE := 'Global Declarations', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc clt$parameter_list
*copyc clt$parameter_list_text_size
*copyc clt$path_display_chunks
*IF $true(osv$unix)
*copyc cyt$mips_signal_handler
*IFEND
*copyc ost$status
?? POP ??
*copyc clp$build_standard_title
*copyc clp$close_display
*copyc clp$convert_integer_to_string
*copyc clp$convert_data_to_string
*copyc clp$evaluate_parameters
*copyc clp$get_work_area
*copyc clp$new_display_line
*copyc clp$open_display_reference
*copyc clp$put_data_representation
*copyc clp$put_display
*copyc clp$reset_for_next_display_page
*IF NOT $true(osv$unix)
*copyc osp$establish_block_exit_hndlr
*copyc osp$disestablish_cond_handler
*IFEND

?? TITLE := 'clp$_display_value', EJECT ??

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

*IF NOT $true(osv$unix)
{   PROCEDURE (osm$disv) display_value, display_values, disv (
{     value, values, v: any = $required
{     output, o: file = $output
{     display_options, display_option, do: list of key
{         (elements, element, e)
{         (compressed_labeled_elements, cle)
{         (data_structure, das, ds)
{         (display_elements, display_element, de)
{         (display_source, dis)
{         (labeled_elements, le)
{         (source, s)
{       keyend = osd$disv_display_options, elements
{     status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 9] of clt$pdt_parameter_name,
      parameters: array [1 .. 4] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
      recend,
      type2: record
        header: clt$type_specification_header,
        default_value: string (7),
      recend,
      type3: record
        header: clt$type_specification_header,
        qualifier: clt$list_type_qualifier_v2,
        element_type_spec: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 17] of clt$keyword_specification,
        recend,
        default_name: string (24),
        default_value: string (8),
      recend,
      type4: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [90, 2, 22, 11, 24, 0, 623],
    clc$command, 9, 4, 1, 0, 0, 0, 4, 'OSM$DISV'], [
    ['DISPLAY_OPTION                 ',clc$alias_entry, 3],
    ['DISPLAY_OPTIONS                ',clc$nominal_entry, 3],
    ['DO                             ',clc$abbreviation_entry, 3],
    ['O                              ',clc$abbreviation_entry, 2],
    ['OUTPUT                         ',clc$nominal_entry, 2],
    ['STATUS                         ',clc$nominal_entry, 4],
    ['V                              ',clc$abbreviation_entry, 1],
    ['VALUE                          ',clc$nominal_entry, 1],
    ['VALUES                         ',clc$alias_entry, 1]],
    [
{ 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, 12, clc$required_parameter,
  0, 0],
{ PARAMETER 2
    [5, 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 3
    [2, 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, 652,
  clc$optional_default_parameter, 24, 8],
{ PARAMETER 4
    [6, 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], [-$clt$type_kinds [],
    FALSE, 0]],
{ PARAMETER 2
    [[1, 0, clc$file_type],
    '$output'],
{ PARAMETER 3
    [[1, 0, clc$list_type], [636, 1, clc$max_list_size, 0, FALSE, FALSE],
      [[1, 0, clc$keyword_type], [17], [
      ['CLE                            ', clc$abbreviation_entry, clc$normal_usage_entry, 2],
      ['COMPRESSED_LABELED_ELEMENTS    ', clc$nominal_entry, clc$normal_usage_entry, 2],
      ['DAS                            ', clc$alias_entry, clc$normal_usage_entry, 3],
      ['DATA_STRUCTURE                 ', clc$nominal_entry, clc$normal_usage_entry, 3],
      ['DE                             ', clc$abbreviation_entry, clc$normal_usage_entry, 4],
      ['DIS                            ', clc$abbreviation_entry, clc$normal_usage_entry, 5],
      ['DISPLAY_ELEMENT                ', clc$alias_entry, clc$normal_usage_entry, 4],
      ['DISPLAY_ELEMENTS               ', clc$nominal_entry, clc$normal_usage_entry, 4],
      ['DISPLAY_SOURCE                 ', clc$nominal_entry, clc$normal_usage_entry, 5],
      ['DS                             ', clc$abbreviation_entry, clc$normal_usage_entry, 3],
      ['E                              ', clc$abbreviation_entry, clc$normal_usage_entry, 1],
      ['ELEMENT                        ', clc$alias_entry, clc$normal_usage_entry, 1],
      ['ELEMENTS                       ', clc$nominal_entry, clc$normal_usage_entry, 1],
      ['LABELED_ELEMENTS               ', clc$nominal_entry, clc$normal_usage_entry, 6],
      ['LE                             ', clc$abbreviation_entry, clc$normal_usage_entry, 6],
      ['S                              ', clc$abbreviation_entry, clc$normal_usage_entry, 7],
      ['SOURCE                         ', clc$nominal_entry, clc$normal_usage_entry, 7]]
      ]
    ,
    'OSD$DISV_DISPLAY_OPTIONS',
    'elements'],
{ PARAMETER 4
    [[1, 0, clc$status_type]]];

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

    CONST
      p$value = 1,
      p$output = 2,
      p$display_options = 3,
      p$status = 4;

    VAR
      pvt: array [1 .. 4] of clt$parameter_value;
*ELSE
{  PROCEDURE (osm$disv) display_value, display_values, disv (
{    value, values, v: any = $required
{    output, o: file = $output
{    display_options, display_option, do: list of key
{        (elements, element, e)
{        (compressed_labeled_elements, cle)
{        (data_structure, das, ds)
{        (display_elements, display_element, de)
{        (display_source, dis)
{        (labeled_elements, le)
{        (source, s)
{      keyend = OSD_DISV_DISPLAY_OPTIONS, elements
{    status)


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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 9] of clt$pdt_parameter_name,
      parameters: array [1 .. 4] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier_v2,
      recend,
      type2: record
        header: clt$type_specification_header,
        default_value: ALIGNED [0 MOD 4] string (7),
      recend,
      type3: record
        header: clt$type_specification_header,
        qualifier: clt$list_type_qualifier_v2,
        element_type_spec: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 17] of clt$keyword_specification,
        recend,
        default_name: ALIGNED [0 MOD 4] string (24),
        default_value: ALIGNED [0 MOD 4] string (8),
      recend,
      type4: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [2,
    [92, 3, 5, 15, 32, 22, 0],
    clc$command, 9, 4, 1, 0, 0, 0, 4, 'OSM$DISV'], [
    ['DISPLAY_OPTION                 ',clc$alias_entry, 3],
    ['DISPLAY_OPTIONS                ',clc$nominal_entry, 3],
    ['DO                             ',clc$abbreviation_entry, 3],
    ['O                              ',clc$abbreviation_entry, 2],
    ['OUTPUT                         ',clc$nominal_entry, 2],
    ['STATUS                         ',clc$nominal_entry, 4],
    ['V                              ',clc$abbreviation_entry, 1],
    ['VALUE                          ',clc$nominal_entry, 1],
    ['VALUES                         ',clc$alias_entry, 1]],
    [
{ 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, 16, clc$required_parameter, 0, 0],
{ PARAMETER 2
    [5, 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 3
    [2, 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, 716, clc$optional_default_parameter, 24, 8],
{ PARAMETER 4
    [6, 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
    [[2, 0, clc$union_type], [-$clt$type_kinds_v2 [],
    FALSE, 0]],
{ PARAMETER 2
    [[2, 0, clc$file_type],
    '$output'],
{ PARAMETER 3
    [[2, 0, clc$list_type], [688, 1, clc$max_list_size, 0, FALSE, FALSE],
      [[2, 0, clc$keyword_type], [17], [
      ['CLE                            ', clc$abbreviation_entry,
  clc$normal_usage_entry, 2],
      ['COMPRESSED_LABELED_ELEMENTS    ', clc$nominal_entry,
  clc$normal_usage_entry, 2],
      ['DAS                            ', clc$alias_entry,
  clc$normal_usage_entry, 3],
      ['DATA_STRUCTURE                 ', clc$nominal_entry,
  clc$normal_usage_entry, 3],
      ['DE                             ', clc$abbreviation_entry,
  clc$normal_usage_entry, 4],
      ['DIS                            ', clc$abbreviation_entry,
  clc$normal_usage_entry, 5],
      ['DISPLAY_ELEMENT                ', clc$alias_entry,
  clc$normal_usage_entry, 4],
      ['DISPLAY_ELEMENTS               ', clc$nominal_entry,
  clc$normal_usage_entry, 4],
      ['DISPLAY_SOURCE                 ', clc$nominal_entry,
  clc$normal_usage_entry, 5],
      ['DS                             ', clc$abbreviation_entry,
  clc$normal_usage_entry, 3],
      ['E                              ', clc$abbreviation_entry,
  clc$normal_usage_entry, 1],
      ['ELEMENT                        ', clc$alias_entry,
  clc$normal_usage_entry, 1],
      ['ELEMENTS                       ', clc$nominal_entry,
  clc$normal_usage_entry, 1],
      ['LABELED_ELEMENTS               ', clc$nominal_entry,
  clc$normal_usage_entry, 6],
      ['LE                             ', clc$abbreviation_entry,
  clc$normal_usage_entry, 6],
      ['S                              ', clc$abbreviation_entry,
  clc$normal_usage_entry, 7],
      ['SOURCE                         ', clc$nominal_entry,
  clc$normal_usage_entry, 7]]
      ]
    ,
    'OSD_DISV_DISPLAY_OPTIONS',
    'elements'],
{ PARAMETER 4
    [[2, 0, clc$status_type]]];

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

    CONST
      p$value = 1,
      p$output = 2,
      p$display_options = 3,
      p$status = 4;

    VAR
      pvt: array [1 .. 4] of clt$parameter_value;
*IFEND

*copy clv$display_variables
?? NEWTITLE := 'abort_handler', EJECT ??

    PROCEDURE abort_handler
*IF $true(osv$unix)
      (    signal_no: integer;
           code: integer;
           p_sigcontext: ^cyt$mips_sigcontext);

      VAR
        ignore_status: ost$status;
*ELSE
      (    ignore_condition: pmt$condition;
           ignore_condition_information: ^pmt$condition_information;
           ignore_save_area: ^ost$stack_frame_save_area;
       VAR handler_status: ost$status);
*IFEND

      IF output_open THEN
*IF $true(osv$unix)
        clp$close_display (display_control, ignore_status);
*ELSE
        clp$close_display (display_control, handler_status);
*IFEND
        output_open := FALSE;
      IFEND;
*IF NOT $true(osv$unix)
      handler_status.normal := TRUE;
*IFEND

    PROCEND abort_handler;
*copy clp$new_page_procedure
?? TITLE := 'put_subtitle', EJECT ??

    PROCEDURE [INLINE] put_subtitle
      (VAR display_control: clt$display_control;
       VAR status: ost$status);


      { The display_value command has no subtitles,
      { this is merely a dummy routine used to keep
      { the module consistent with those that do produce subtitles.

    PROCEND put_subtitle;
?? OLDTITLE, EJECT ??

    CONST
      subtitle_header = 'display option: ',
      subtitle_header_size = 16;

    VAR
      current_option: ^clt$data_value,
*IF NOT $true(osv$unix)
      default_ring_attributes: amt$ring_attributes,
*IFEND
      display_control: clt$display_control,
*IF $true(osv$unix)
      handler_established: boolean,
*IFEND
      i: clt$data_representation_count,
      local_status: ost$status,
      option: clt$data_representation_option,
      option_name: clt$keyword,
      output_open: boolean,
      representation: ^clt$data_representation,
      string_count: ^clt$data_representation_count,
      string_ptr: ^clt$string_value,
      string_size: ^clt$string_size,
      subtitle: string (subtitle_header_size + osc$max_name_size),
      work_area: ^^clt$work_area;


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

*IF NOT $true(osv$unix)
    clp$get_work_area (#RING (^work_area), work_area, status);
*ELSE
    clp$get_work_area (osc$user_ring, work_area, status);
*IFEND
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    output_open := FALSE;
*IF NOT $true(osv$unix)
    osp$establish_block_exit_hndlr (^abort_handler);

*IF NOT $true(osv$unix)
    default_ring_attributes.r1 := #RING (^default_ring_attributes);
    default_ring_attributes.r2 := #RING (^default_ring_attributes);
    default_ring_attributes.r3 := #RING (^default_ring_attributes);
*ELSE
    default_ring_attributes.r1 := osc$user_ring;
    default_ring_attributes.r2 := osc$user_ring;
    default_ring_attributes.r3 := osc$user_ring;
*IFEND
    clp$open_display_reference (pvt [p$output].value^.file_value^, ^clp$new_page_procedure, fsc$list,
          default_ring_attributes, display_control, status);
    IF NOT status.normal THEN
      osp$disestablish_cond_handler;
*ELSE
    handler_established := #establish_condition_handler (-1, ^abort_handler);

    clp$open_display_reference (pvt [p$output].value^.file_value^, ^clp$new_page_procedure, fsc$list,
          display_control, status);
    IF NOT status.normal THEN
      IF handler_established THEN
        handler_established := NOT #disestablish_condition_handler (-1);
      IFEND;
*IFEND
      RETURN;
    IFEND;
    output_open := TRUE;
    clv$titles_built := FALSE;
    clv$command_name := 'display_value';

    subtitle := subtitle_header;

    current_option := pvt [p$display_options].value;

  /option_loop/
    WHILE current_option <> NIL DO
      option_name := current_option^.element_value^.keyword_value;

*IF NOT $true(osv$unix)
      IF (display_control.page_format <> amc$untitled_form) AND pvt [p$display_options].specified AND
            (pvt [p$display_options].value^.link <> NIL) THEN
*ELSE
      IF pvt [p$display_options].specified AND
            (pvt [p$display_options].value^.link <> NIL) THEN
*IFEND
        subtitle (subtitle_header_size + 1, * ) := option_name;
        IF current_option <> pvt [p$display_options].value THEN
          clp$new_display_line (display_control, 2, status);
          IF NOT status.normal THEN
            EXIT /option_loop/;
          IFEND;
        IFEND;
        clp$put_display (display_control, subtitle, clc$trim, status);
        IF NOT status.normal THEN
          EXIT /option_loop/;
        IFEND;
        clp$new_display_line (display_control, 1, status);
        IF NOT status.normal THEN
          EXIT /option_loop/;
        IFEND;
      IFEND;

      IF option_name = 'ELEMENTS' THEN
        option := clc$data_elem_representation;
      ELSEIF option_name = 'COMPRESSED_LABELED_ELEMENTS' THEN
        option := clc$compressed_labeled_elem_rep;
      ELSEIF option_name = 'DISPLAY_ELEMENTS' THEN
        option := clc$display_elem_representation;
      ELSEIF option_name = 'DISPLAY_SOURCE' THEN
        option := clc$display_srce_representation;
      ELSEIF option_name = 'DATA_STRUCTURE' THEN
        option := clc$data_struct_representation;
      ELSEIF option_name = 'LABELED_ELEMENTS' THEN
        option := clc$labeled_elem_representation;
      ELSE { option_name = 'SOURCE' }
        option := clc$data_source_representation;
      IFEND;

*IF NOT $true(osv$unix)
      clp$convert_data_to_string (pvt [p$value].value, option, display_control.page_width, work_area^,
*ELSE
      clp$convert_data_to_string (pvt [p$value].value, option, 80, work_area^,
*IFEND
            representation, status);
      IF NOT status.normal THEN
        EXIT /option_loop/;
      IFEND;
      clp$put_data_representation (display_control, representation, status);
      IF NOT status.normal THEN
        EXIT /option_loop/;
      IFEND;

      RESET work_area^ TO representation;
      current_option := current_option^.link;
    WHILEND /option_loop/;

    clp$close_display (display_control, local_status);
    output_open := FALSE;
    IF status.normal AND (NOT local_status.normal) THEN
      status := local_status;
    IFEND;

*IF $true(osv$unix)
    IF handler_established THEN
      handler_established := NOT #disestablish_condition_handler (-1);
    IFEND;
*ELSE
    osp$disestablish_cond_handler;
*IFEND

  PROCEND clp$_display_value;

MODEND clm$display_value_command;
