PROCEDURE  define_network, define_networks, defn (
  )

  IF NOT $job(operator) THEN
    text = 'DEFINE_NETWORK'//$char(31)//'except from the console'
    EXIT_PROC WITH $status(FALSE, 'RA', rae$illegal_command_call, text)
  IFEND

  create_variable choice k=string
  create_variable cr_requested k=string
  create_variable local_status k=status
  create_variable ignore_status k=status

  create_variable physical_data k=string d=0..9
  create_variable system_id_array k=string d=0..9 v=' '
  create_variable defined_array k=string d=0..9 v=' '
  create_variable host_network_id k=string v=' '
  create_variable permanent_config_file k=string v='$system.network.configuration'

main_loop: ..
  LOOP
"$ format=off
    put_line (..
     '1Define Network'..
     '01. Define the network configuration'..
     ' 2. Define the CDCNET configuration'..
     ' 3. Activate the network'..
     ' 4. Define the Timesharing application'..
     '0Enter a menu selection, QUIT, or ?: '..
    )
"$ format=on
    choice = ''
    accept_line choice input p=''

    IF choice = '1' THEN

      define_network_config host_network_id physical_data system_id_array defined_array

    ELSEIF choice = '2' THEN

      create_cdcnet_config_procs

    ELSEIF choice = '3' THEN

      IF $file($fname(permanent_config_file), permanent) THEN
        detach_file $fname(permanent_config_file) status=ignore_status
        activate_network status=local_status
        IF local_status.normal THEN
          put_line '  '
          accept_line cr_requested input p='Press NEXT: '
        ELSE
          display_value local_status
          put_line '  '
          accept_line cr_requested input p='Press NEXT: '
        IFEND
      ELSE
        put_line ('0Network configuration must be installed before the network can be activated.' '  ')
        accept_line cr_requested input p='Press NEXT: '
      IFEND

    ELSEIF choice = '4' THEN

      define_timesharing

    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) = 'HELP') THEN

      define_network_help

    ELSEIF choice = ' ' THEN

      " Do nothing if the user types-ahead."

    ELSE

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

    IFEND

  LOOPEND main_loop

PROCEND define_network
