PROC define_channel_network (
  physical_data_array  : array of string = $optional
  host_network         : string = $required
  network_ids          : array of string = $optional
  system_ids           : array of string = $required
  relays               : array of string = $optional
  physical_entries     : integer = $optional
  lcu_entries          : var of integer = $optional
  status               : var of status = $optional
  )

" Make local copies of the procedure parameters.

  physical_data = $value(physical_data_array)
  host_network_id = $value(host_network)
  network_id_array = $value(network_ids)
  system_id_array = $value(system_ids)
  rr_array = $value(relays)
  number_physical_entries = $value(physical_entries)
  number_lcu_entries = $value(lcu_entries)

  create_variable (choice cr_requested) k=string
  create_variable conversion_status k=status
  create_variable i k=integer
  create_variable successful boolean

main_loop: ..
  LOOP

    put_line ('1Define Channel Network'..
          '0Choose channel network to define or modify:' ..
          '0                                        Channel Serial   Relays   Network' ..
          '         Element Name                     Number Number Restricted Identifier'..
          '  ')
    FOR di_number = 1 TO number_physical_entries DO
      text = physical_data(di_number) // '     ' // $substr(rr_array(di_number), 1, 7) //..
            network_id_array(di_number)
      put_line text
    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

      put_line (..
            '0This menu prompts you to define the network configuration of your '..
            ' mainframe. The network configuration consists of channel networks'..
            ' which are connections between a CYBER channel and a CDCNET DI.  The'..
            ' channel networks for this mainframe are displayed as menu selections.'..
            '0Enter a menu selection to set the parameters for a channel network.'..
            ' Enter GO or press NEXT to install the network configuration'..
            '   you have defined.'..
            ' Enter QUIT to return to the main menu without installing the'..
            '   configuration.  Any network configuration parameters you have set'..
            '   will be lost.'..
            '  ')
      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

      install_network_config_file TRUE host_network_id network_id_array system_id_array rr_array physical_data ..
          number_physical_entries number_lcu_entries success=successful
      IF successful THEN
        $value(network_ids) = network_id_array
        $value(relays) = rr_array
        $value(lcu_entries) = number_lcu_entries
        EXIT main_loop
      IFEND

    ELSE
      include_line 'i = $integer(choice)' status=conversion_status
      IF conversion_status.normal THEN
        IF (i >= 1) AND (i <= number_physical_entries) THEN
          prompt_for_channel_network physical_data(i) host_network_id number_physical_entries rr_array(i) network_id_array(i) ..
               number_lcu_entries
          CYCLE main_loop
        IFEND
      IFEND
      put_line '  '
      accept_line cr_requested input p='Invalid selection, press NEXT: '
    IFEND

  LOOPEND main_loop

PROCEND define_channel_network
