PROCEDURE install_cdcnet_configuration inscc (
  status)


    create_variable choice k=string
    create_variable local_status k=status
    create_variable yes_response k=boolean



  put_line ('  ',' In order to use the configuration terminal, you must define', ..
                 ' the CDCNET Device Interface''s which connect that terminal', ..
                 ' to the host.') o=$output


define_single_di: ..
  LOOP

    put_line ('  ',' Select the type of Device Interface (DI)', ..
                   '   1) Mainframe Terminal Interface (MTI)', ..
                   '   2) Mainframe Device Interface   (MDI)', ..
                   '   3) Terminal Device Interface    (TDI)')

  type_loop: ..
    LOOP
      accept_line choice input prompt='Enter the number of your choice: '
      include_line 'selection = $integer(choice)' status=local_status
      IF NOT local_status.normal THEN
        put_line '   Invalid selection, please re-enter.'
        CYCLE type_loop
      IFEND

      IF selection = 1 THEN
        di_type = 'MTI'
      ELSEIF selection = 2 THEN
        di_type = 'MDI'
      ELSEIF selection = 3 THEN
        di_type = 'TDI'
      ELSE
        put_line ' Invalid selection, please re-enter.'
        CYCLE type_loop
      IFEND

      $system.osf$builtin_library.prompt_for_answer ..
            'Is the selection of '//di_type//' correct?' yes_response
      EXIT type_loop WHEN yes_response
    LOOPEND type_loop

    put_line ('  ',' Enter the last six digits of the 12 hexadecimal digit DI system', ..
                   ' identifier.  For example, if the system identifier is 08002510007C, enter', ..
                   ' the value 10007C.  You should not include the (16) radix.')

  system_id_loop: ..
    LOOP
      accept_line choice input prompt='Enter the last six hexadecimal digits: '
      system_identifier = $translate(lower_to_upper, choice)
      length = $strlen(choice)
      IF length < 6 THEN
        system_identifier = $substr('000000', 1, 6-length) // system_identifier
      ELSEIF length > 6 THEN
        put_line ' You may only enter six hexadecimal digits. Please re-enter.'
        CYCLE system_id_loop
      IFEND

      include_line 'system_id = $integer(''0''//system_identifier//''(16)'')' status=local_status
      IF NOT local_status.normal THEN
        put_line ' Invalid digits given. Please re-enter.'
        CYCLE system_id_loop
      IFEND

      $system.osf$builtin_library.prompt_for_answer ..
            'Are the six hexadecimal digits '//system_identifier//' correct?' yes_response
      EXIT system_id_loop WHEN yes_response
    LOOPEND system_id_loop

    procedure_name = 'SYSTEM_080025' // system_identifier

    $system.osf$builtin_library.add_device_interface t=$name(di_type) ..
          pn=$name(procedure_name) status=local_status
    IF NOT local_status.normal THEN
      put_line ' '//$strrep(local_status)
    IFEND

    $system.osf$builtin_library.prompt_for_answer ..
          'Do you need to define another Device Interface (DI)?' yes_response
    EXIT define_single_di WHEN NOT yes_response
  LOOPEND define_single_di

  EXIT_PROC WITH local_status

PROCEND install_cdcnet_configuration
