PROC prompt_for_tup (
  tup : var of string = $optional
  status)

  create_variable count k=integer
  create_variable cr_requested k=string
  create_variable help_file k=string v='$local.'//$unique
  create_variable help_line k=string d=16
  create_variable input_string k=string
  create_variable local_status k=status
  create_variable user k=string v='$system.cdcnet.site_controlled.procedures.user'

  set_file_attributes f=$fname(help_file) pf=c
  $system.osf$command_library.display_object_library l=$fname(user) do=none o=$fname(help_file) ao=true

tup_loop: ..
  LOOP
    put_line '0Enter the name of the tup to configure with your terminal or ? for help:'
    accept_line input_string input p=''

    IF (input_string = '?') OR ($translate(lower_to_upper, input_string) = 'HELP') THEN
      put_line ('1Supply the name of the TUP with which to configure your terminal.' ..
                ' A description of the TUPs can be found in the CDCNET Configuration ' ..
                ' and Site Administration Guide Appendix J.' ..
                ' If you do not wish to specify a TUP, Press NEXT.' ..
                ' You have the choice of any of the following TUPs:')
      rewind_file $fname(help_file)
      REPEAT
         accept_line v=help_line i=$fname(help_file//'.$asis') lc=count
         for i=1 to count do
           put_line help_line(i)
         forend
         put_line ' '
         accept_line cr_requested input p='Press NEXT: '
         put_line ' '
      UNTIL count < 16
    ELSEIF input_string = ' ' THEN
      EXIT tup_loop
    ELSEIF ($translate(lower_to_upper, input_string) = 'QUIT') OR ($translate(lower_to_upper, input_string) = 'QUI') THEN
      $value(tup) = ' '
      EXIT tup_loop
    ELSE
       $value(tup) = $translate(lower_to_upper, input_string)
       PUSH file_connections
         delete_file_connection $errors output
         $system.osf$command_library.display_object_library l=$fname(user) m=$name($value(tup)) o=$null ..
               status=local_status
       POP file_connections
       IF local_status.normal THEN
         EXIT tup_loop
       ELSE
         put_line '0 --ERROR--  '//$value(tup)//' is not in '//user//'.' o=$response
         $value(tup) = ' '
       IFEND
    IFEND
  LOOPEND tup_loop
  detach_file $fname(help_file)

PROCEND prompt_for_tup
