PROC prompt_for_timesharing_titles (
  titles, t: array of string = $required
  changes_accepted, ca: VAR of boolean = $required
  status)


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'

"    The purpose of this request is to allow the site to define up
"to MAX_TITLES timesharing titles.  This request is called by
"DEFINE_TIMESHARING, and follows the menu format of all
"DEFINE_NETWORK procedures.  The titles are actually processed by
"PROCESS_TIMESHARING_TITLES.
*IFEND


  create_variable choice k=string
  create_variable command_file k=string v='$local.'//$unique
  create_variable conversion_status k=status
  create_variable example_title k=string v='sys'//$strrep($integer($substr($mainframe(identifier), 14, 4)))
  create_variable ignore_status k=status
  create_variable input_line k=string
  create_variable menu k=string v='$local.'//$unique
  create_variable local_status k=status
  create_variable prompted k=string
  create_variable title_count k=integer

main_loop: ..
  LOOP

    collect_text $fname(menu//'.$boi') until='    END_COLLECT'
      put_line ('1Current timesharing titles ......', ..
    END_COLLECT
    title_count = 0
    FOR i = 1 TO $upperbound(titles) DO
      IF titles(i) <> '' THEN
        put_line '''  '//titles(i)//''', ..' o=$fname(menu//'.$eoi')
        title_count = title_count + 1
      IFEND
    FOREND
    put_line ('''01. Add titles'', '' 2. Delete titles'',''  '')') o=$fname(menu//'.$eoi')
    include_file $fname(menu) status=ignore_status
    $system.detach_file $fname(menu) status=ignore_status

    accept_line choice input p='Enter a menu selection, QUIT, GO, or ?:'
    IF choice <> '' THEN
      front = $scan_not_any(' ', choice)
      choice = $translate(lower_to_upper, $trim($substr(choice, front, ($strlen(choice)-front+1))))
    IFEND

    IF choice = '1' THEN
    add_titles: ..
      LOOP
        accept_line input_line input p='Enter timesharing title(s) to be added or ? for help:'
        IF input_line = '' THEN
          EXIT add_titles
        IFEND
        front = $scan_not_any(' ', input_line)
        input_line = $translate(lower_to_upper, $trim($substr(input_line, front, ($strlen(input_line)-front+1))))
        IF input_line = '?' THEN
          put_line ('0Enter the title(s) you want this NOS/VE timesharing application to be known' ..
                    ' by.  The title chosen must be unique from all other titles in the CDCNET ' ..
                    ' concatenated network (catenet).  Multiple titles can be entered separated by ' ..
                    ' a space.  A title must be a valid SCL name.', '  ')


          accept_line prompted input p='Press NEXT:'
        ELSE
          $system.osf$builtin_library.process_timesharing_titles input_line p=add t=titles
          EXIT add_titles
        IFEND
      LOOPEND add_titles

    ELSEIF choice = '2' THEN
    delete_titles: ..
      LOOP
        accept_line input_line input p='Enter timesharing title(s) to be deleted or ? for help:'
        IF input_line = '' THEN
          EXIT delete_titles
        IFEND
        front = $scan_not_any(' ', input_line)
        input_line = $translate(lower_to_upper, $trim($substr(input_line, front, ($strlen(input_line)-front+1))))
        IF input_line = '?' THEN
          put_line ('0Enter the application title(s) you want to delete from the current' ..
                    ' timesharing titles list.  Multiple titles can be entered separated by' ..
                    ' a space.', '  ')
          accept_line prompted input p='Press NEXT:'
        ELSE
          $system.osf$builtin_library.process_timesharing_titles input_line p=delete t=titles
          EXIT delete_titles
        IFEND
      LOOPEND delete_titles

    ELSEIF (choice = 'QUIT') OR (choice = 'QUI') THEN
      changes_accepted = FALSE
      titles_added = FALSE
      EXIT main_loop

    ELSEIF (choice = '?') OR (choice = 'HELP') THEN
      put_line (..
        '0You are required to provide the title(s) by which NOS/VE users' ..
        ' connect to the timesharing application.  The user connects to the' ..
        ' application via the CDCNET CREATE_CONNECTION command which requires' ..
        ' an application title, for example:' ..
        '       create_connection '//example_title ..
        ' The title(s) chosen must be unique from all other titles in the CDCNET ' ..
        ' concatenated network (catenet).  The example title, '//example_title//' was ' ..
        ' generated using your mainframe''s serial number.  A title must be a valid ' ..
        ' SCL name (1 to 31 alphabetic characters, digits, _, $, #, and/or @,' ..
        ' beginning with a nondigit).' ..
        '0Enter a menu selection to add or delete titles.' ..
        ' Enter GO or press NEXT to define the timesharing application with the' ..
        ' current list of titles.' ..
        ' Enter QUIT or QUI to return to the main menu without any changes.')

      accept_line prompted input p='Press NEXT:'

    ELSEIF (choice = ' ') OR (choice = 'GO') THEN
      IF title_count = 0 THEN
        put_line '0No Timesharing titles are defined.'
        accept_line prompted input p='Press NEXT:'
      ELSE
        changes_accepted = TRUE
        titles_added = TRUE
        EXIT main_loop
      IFEND

    ELSE
      accept_line prompted input p='Invalid selection, press NEXT:'
    IFEND
  LOOPEND main_loop

PROCEND prompt_for_timesharing_titles
