PROCEDURE define_network_config (
  host_network            : (var) string = $required
  physical_data_array     : (var) array of string = $required
  system_ids              : (var) array of string = $required
  def_array               : (var) array of string = $required
  status)

" Make local copies of the procedure parameters.

  physical_data = physical_data_array
  system_id_array = system_ids
  host_network_id = host_network
  defined_array = def_array

  VAR
    choice: string
    conversion_status: status
    cr_requested: string
    forward_search: string='4(10)'
    host_name: string=' '
    number_physical_entries: integer
    successful: boolean
    termination_desired: boolean
  VAREND

  IF $namve_active THEN
    prompt_for_active_network termination_desired
    EXIT_PROC WITH $status(TRUE) WHEN termination_desired
  IFEND

  get_physical_information physical_data number_physical_entries

  IF number_physical_entries = 0 THEN
    put_line (' Network device definitions must exist in order ' ..
              ' to define a network configuration'..
              '0 ')
    accept_line cr_requested input p='Press NEXT: '
    EXIT_PROC WITH $status(true)
  IFEND

main_loop: ..
  LOOP
"$ format=off
    put_line (..
     '1Define the Network Configuration'..
     '01. Define the Network Connections'..
     ' 2. Define the TCP/IP Host'..
     '0Enter a menu selection, GO, QUIT, or ?: '..
    )
"$ format=on
    choice = ''
    accept_line choice input p=''

    IF choice = '1' THEN

      prompt_for_host_network host_network_id
      IF host_network_id = ' ' THEN
        EXIT_PROC
      IFEND

      define_network_connection  physical_data host_network_id system_id_array number_physical_entries defined_array

    ELSEIF choice = '2' THEN

      define_tcpip_host host_name=host_name forward_search_range=forward_search
      IF host_name = ' ' THEN
        forward_search='4(10)'
      IFEND

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

"$ format = off
      put_line (..
       ' Enter GO or press NEXT to install the network configuration you have defined.' ..
       '    If you defined more than one device (i.e., MDI, ICA_II, or EXPRESSLink),'..
       '    you must define a VE interface network identifier for each MDI or ICA_II'..
       '    before activating NAM/VE.  (Use: main menu selection 2. Define the CDCNET'..
       '    configuration and subordinates to define VE interface network identifiers.)'..
       ' Enter QUIT to return to the main menu without installing 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_PROC

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

        install_network_config_file  host_network_id  system_id_array  ..
              physical_data number_physical_entries defined_array host_name ..
              forward_search successful
        IF successful THEN
          EXIT main_loop
        IFEND

      ELSE
        put_line '  '
        accept_line cr_requested input p='Invalid selection, press NEXT: '
      IFEND

    LOOPEND main_loop

  physical_data_array = physical_data
  system_ids = system_id_array
  host_network = host_network_id
  def_array = defined_array

PROCEND define_network_config
