PROCEDURE define_network_connection (
  physical_data_array: (var) array of string = $required
  host_network_id: string = $required
  system_ids: (var) array of string = $required
  number_physical_entries: integer = $required
  def_array: (var) array of string = $required
  status)


" This procedure prompts the user to add/delete network devices to/from
" the network configuration.  All available network devices that can be added/deleted
" are displayed as options.  By selecting an option, the user may add or
" delete that particular device to/from the network configuration.
" When adding an ICA-II to the network configuration, the user is prompted to
" enter in a 6 digit (hex) system identifier number.

" Make local copies of parameters.

  physical_data = physical_data_array
  system_id_array = system_ids
  defined_array = def_array

"$ format = off
  VAR
    choice: string
    conversion_status: status
    cr_requested: string
    selection: integer
    successful: boolean
  VAREND
"$ format = on


  main_loop: ..
    LOOP

 "$ format= off
    put_line ('1Define a Network Connection' ..
          '0Choose network connection to add or delete:' ..
          '0                                                             (ICA-II ONLY)' ..
          '   Add to the   Type of                                           System  ' ..
          '    Network?    Device   Connected System/Element Name        Identification', ' ')
"$ format= on

      FOR i = 1 TO number_physical_entries DO
        put_line (' '//$strrep(i)//'.  '//$substring(defined_array(i),1,12,' ')//$substring(physical_data(i),5,5)//..
'   '//$substring(physical_data(i),11,31)//'        '//$substring(system_id_array(i),1,13))
      FOREND

      put_line ('0Enter a menu selection, QUIT, GO, or ?: ')
      choice = ''

      accept_line choice input p=''

      IF (choice = '?') OR ($translate(lower_to_upper, choice) = 'HELP') THEN

"$ format = off
        put_line ('0This menu prompts you to add/delete network devices to/from ' ..
              ' your network configuration.  The network configuration defines which ' ..
              ' network devices your mainframe is to recognize on the network.' ..
              '0Enter a menu selection to add/delete it to/from the network configuration.' ..
              ' Enter GO or press NEXT to save the network configuration you have defined.' ..
              ' Enter QUIT to return to the define network menu without saving the' ..
              '   configuration.  Any network configuration parameters you have set' ..
              '   will be lost.' ..
              '  ')
"$ format = on
        accept_line cr_requested input p='Press NEXT: '

      ELSEIF ($translate(lower_to_upper, choice) = 'QUIT') OR ($translate(lower_to_upper, choice) = 'QUI') ..
            THEN

        EXIT main_loop

      ELSEIF (choice = ' ') OR ($translate(lower_to_upper, choice) = 'GO') THEN

        physical_data_array = physical_data
        system_ids = system_id_array
        def_array = defined_array
        EXIT main_loop

      ELSE
        include_line 'selection = $integer(choice)' status=conversion_status
        IF conversion_status.normal THEN
          IF (selection >= 1) AND (selection <= number_physical_entries) THEN
            prompt_for_add_element physical_data(selection) system_id_array(selection) defined_array(selection)
            CYCLE main_loop
          IFEND
        IFEND
        put_line '  '
        accept_line cr_requested input p='Invalid selection, press NEXT: '
      IFEND

    LOOPEND main_loop

PROCEND define_network_connection
