?? RIGHT := 110 ??
MODULE clm$tape_scan_commands;

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc clc$max_integer
*copyc clt$value
*copyc clt$display_control
*copyc ofe$error_codes
*copyc ost$status
*copyc ost$string
?? POP ??

*copyc clp$convert_integer_to_string
*copyc clp$evaluate_parameters
*copyc iop$change_tape_scan_freq_23d
*copyc iop$fetch_tape_scan_frequency
*copyc osp$establish_condition_handler

  PROCEDURE [XDCL, #GATE] clp$_change_tape_scan_freq_cmd
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE change_tape_scan_frequency (
{   scan_frequency: integer 1..clc$max_integer = $required
{   status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 2] of clt$pdt_parameter_name,
      parameters: array [1 .. 2] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$integer_type_qualifier,
      recend,
      type2: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [91, 12, 5, 18, 23, 0, 540],
    clc$command, 2, 2, 1, 0, 0, 0, 2, ''], [
    ['SCAN_FREQUENCY                 ',clc$nominal_entry, 1],
    ['STATUS                         ',clc$nominal_entry, 2]],
    [
{ PARAMETER 1
    [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, 20, clc$required_parameter,
  0, 0],
{ PARAMETER 2
    [2, 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$integer_type], [1, clc$max_integer, 10]],
{ PARAMETER 2
    [[1, 0, clc$status_type]]];

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

    CONST
      p$scan_frequency = 1,
      p$status = 2;

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

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

    iop$change_tape_scan_freq_23d (pvt [p$scan_frequency].value^.integer_value.value, status);

  PROCEND clp$_change_tape_scan_freq_cmd;

  PROCEDURE [XDCL, #GATE] clp$_display_tape_scan_freq_cmd
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE display_tape_scan_frequency, distsf (
{   output, o: file = $output
{   status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 3] of clt$pdt_parameter_name,
      parameters: array [1 .. 2] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        default_value: string (7),
      recend,
      type2: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [91, 11, 26, 16, 48, 5, 297],
    clc$command, 3, 2, 0, 0, 0, 0, 2, ''], [
    ['O                              ',clc$abbreviation_entry, 1],
    ['OUTPUT                         ',clc$nominal_entry, 1],
    ['STATUS                         ',clc$nominal_entry, 2]],
    [
{ PARAMETER 1
    [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, 3,
  clc$optional_default_parameter, 0, 7],
{ PARAMETER 2
    [3, 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$file_type],
    '$output'],
{ PARAMETER 2
    [[1, 0, clc$status_type]]];

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

    CONST
      p$output = 1,
      p$status = 2;

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

*copyc clp$abort_handler
*copyc clp$build_path_subtitle
*copyc clp$build_standard_title
*copyc clp$close_display
*copyc clp$convert_integer_to_string
*copyc clp$convert_string_to_file
*copyc clp$get_parameter
*copyc clp$get_path_description
*copyc clp$get_path_name
*copyc clp$horizontal_tab_display
*copyc clp$new_display_line
*copyc clp$new_page_procedure
*copyc clp$open_display
*copyc clp$put_display
*copyc clp$put_partial_display
*copyc clp$put_partial_display
*copyc clp$put_path_subtitle
*copyc clp$reset_for_next_display_page
*copyc clp$trimmed_string_size
*copyc clv$display_variables
*copyc clv$value_descriptors

?? EJECT ??

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

      clv$subtitles_built := TRUE;

    PROCEND put_subtitle;

?? EJECT ??

    PROCEDURE put_attribute
      (    header: string ( * );
           value: string ( * ));

      VAR
        ignore_status: ost$status,
        start_option: amt$term_option,
        edited_header: string (tab_over);

      CONST
        max_attribute_name_size = 22,
        tab_over = max_attribute_name_size + 3;

      start_option := amc$start;
      edited_header := header;
      edited_header (tab_over - 1) := ':';

      clp$put_partial_display (display_control, edited_header, clc$no_trim, start_option, status);
      IF NOT status.normal THEN
        clp$close_display (display_control, ignore_status);
        EXIT clp$_display_tape_scan_freq_cmd;
      IFEND;
      clp$put_partial_display (display_control, value, clc$trim, amc$terminate, status);
      IF NOT status.normal THEN
        clp$close_display (display_control, ignore_status);
        EXIT clp$_display_tape_scan_freq_cmd;
      IFEND;
    PROCEND put_attribute;
?? EJECT ??

    PROCEDURE clean_up;

      VAR
        ignore_status: ost$status;

      IF output_open THEN
        clp$close_display (display_control, ignore_status);
        output_open := FALSE;
      IFEND;

    PROCEND clean_up;

    {  Begin main procedure  }

    VAR
      value: clt$value,
      display_control: clt$display_control,
      output_file: clt$file,
      output_open: boolean,
      scan_frequency: integer,
      scan_frequency_string: ost$string;

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

    clp$convert_string_to_file (pvt [p$output].value^.file_value^, output_file, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    output_open := FALSE;
    osp$establish_condition_handler (^clp$abort_handler, FALSE);

    clp$open_display (output_file, ^clp$new_page_procedure, display_control, status);
    IF NOT status.normal THEN
      RETURN
    IFEND;
    output_open := TRUE;
    clv$titles_built := FALSE;
    clv$subtitles_built := FALSE;
    clv$command_name := 'display_tape_scan_frequency';

    IF display_control.page_width < clc$narrow_page_width THEN
      clv$page_width := clc$narrow_page_width;
    ELSEIF display_control.page_width > clc$wide_page_width THEN
      clv$page_width := clc$wide_page_width;
    ELSE
      clv$page_width := display_control.page_width;
    IFEND;

    iop$fetch_tape_scan_frequency (scan_frequency, status);
    IF NOT status.normal THEN
      RETURN
    IFEND;

    clp$convert_integer_to_string (scan_frequency, {radix} 10, {include_radix} FALSE, scan_frequency_string,
          status);
    IF NOT status.normal THEN
      RETURN
    IFEND;

    IF status.normal THEN
      IF scan_frequency > 1 THEN
        scan_frequency_string.value (scan_frequency_string.size + 1, 8) := ' seconds';
        scan_frequency_string.size := scan_frequency_string.size + 8;
      ELSE
        scan_frequency_string.value (scan_frequency_string.size + 1, 7) := ' second';
        scan_frequency_string.size := scan_frequency_string.size + 7;
      IFEND;
      put_attribute ('Tape Scan Frequency', scan_frequency_string.
            value (1, scan_frequency_string.size));
    IFEND;

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

  PROCEND clp$_display_tape_scan_freq_cmd;
MODEND clm$tape_scan_commands;
