PROCEDURE configure_lines (
di_procedure_file, dpf: string = $required
line_type, lt: key async_terminal, async_printer, keyend = $required
status)

  create_variable choice k=string
  create_variable cr_requested k=string
  create_variable first_file k=string v='$local.'//$unique
  create_variable ignore_status k=status
  create_variable lim k=string
  create_variable port k=string
  create_variable second_file k=string v='$local.'//$unique
  create_variable tup k=string
  create_variable parity k=string v=' '


configure_lines_loop: ..
  LOOP

If $string($value(line_type)) = 'ASYNC_TERMINAL' THEN
"$ format=off
    put_line (..
     '1Configure a line for an ASYNC terminal.'..
     '01. LIM number .......... '//lim..
     ' 2. PORT number ......... '//port..
     ' 3. TUP name ............ '//tup..
     '0Enter a menu selection, QUIT, GO, or ?:'..
    )
ELSEIF $string($value(line_type)) = 'ASYNC_PRINTER' THEN
"$ format=off
    put_line (..
     '1Configure a line for an ASYNC printer.'..
     '01. LIM number .......... '//lim..
     ' 2. PORT number ......... '//port..
     ' 3. Printer Parity ...... '//parity..
     '0Enter a menu selection, QUIT, GO, or ?:'..
    )
IFEND
"$ format=on
    choice = ' '
    accept_line choice input p=''

    IF choice = '1' THEN

      prompt_for_lim lim

    ELSEIF choice = '2' THEN

      prompt_for_port port

    ELSEIF choice = '3' THEN

      IF $string($value(line_type)) = 'ASYNC_TERMINAL' THEN
        prompt_for_tup tup
      ELSE
        prompt_for_printer_parity parity
      IFEND

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

      EXIT configure_lines_loop

    ELSEIF ((choice = '?') OR ($translate(lower_to_upper, choice) = 'HELP')) AND ..
         ($string($value(line_type)) = 'ASYNC_TERMINAL') THEN

"$ format=off
    put_line (..
     '1By default a terminal is defined on LIM 0 PORT 0.'..
     ' To define another terminal select: ' ..
     '0Number 1 to give the value of the LIM.' ..
     ' Number 2 to give the value of the PORT.' ..
     ' Number 3 to give the name of the TUP. ' ..
     '0You must give values for the LIM and the PORT, but ' ..
     ' the TUP value is optional. ' ..
    )
      accept_line cr_requested input p='Press NEXT: '
"$ format=on

    ELSEIF ((choice = '?') OR ($translate(lower_to_upper, choice) = 'HELP')) AND ..
         ($string($value(line_type)) = 'ASYNC_PRINTER') THEN

"$ format=off
    put_line (..
     '1This procedure defines a line between a CDCNET DI and an ASYNC printer.'..
     ' All printers are configured at a line speed of 9600 baud.' ..
     '0If the name of your Control Facility or Station Name is different than ' ..
     ' the defaults, be sure to change TDP PRINTER_WITHOUT_VFU.  Refer to the ' ..
     ' CDCNET Site Administration and Configuration Guide Appendix J for a' ..
     ' complete description of TDP PRINTER_WITHOUT_VFU.' ..
     '0The operator must define  Status Control Facility Server (SCFS),' ..
     ' Status Control Facility (SCF), Batch Transfer Facility (BTF), ' ..
     ' and Operator Station and activate SCFS and SCF before the printer will ' ..
     ' become active. ' ..
     '0To define an ASYNC printer select: ' ..
     '0Number 1 to give the value of the LIM.' ..
     ' Number 2 to give the value of the PORT.' ..
     ' Number 3 to give the PARITY of the printer. ' ..
    )
      accept_line cr_requested input p='Press NEXT: '
"$ format=on

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

      IF lim = ' ' THEN
        put_line '  '
        accept_line cr_requested input p='LIM is a required value.  Please enter a value for LIM, press NEXT: '
        CYCLE configure_lines_loop
      ELSEIF port = ' ' THEN
        put_line '  '
        accept_line cr_requested input p='PORT is a required value.  Please enter a value for PORT, press NEXT: '
        CYCLE configure_lines_loop
      IFEND

      IF ($string($value(line_type)) = 'ASYNC_PRINTER') AND (parity = ' ') THEN
        put_line '  '
        accept_line cr_requested input p='PARITY is a required value.  Please enter a value for PARITY, press NEXT: '
        CYCLE configure_lines_loop
      IFEND

      IF $string($value(line_type)) = 'ASYNC_TERMINAL' THEN
        IF tup <> ' ' THEN
          put_line l = 'define_line lim = '//lim//', port = '//port//..
', ln = line'//lim//port//', tn = asynctip, lt = dedicated'//..
', ar = scp, tup = '//tup o=$fname(first_file)
        ELSE
          put_line l = 'define_line lim = '//lim//', port = '//port//..
', ln = line'//lim//port//', tn = asynctip, lt = dedicated'//..
', ar = scp ' o=$fname(first_file)
        IFEND
      ELSEIF $string($value(line_type)) = 'ASYNC_PRINTER' THEN
        put_line l = 'define_line lim = '//lim//', port = '//port//..
', ln = line'//lim//port//', tn = asynctip, lt = dedicated'//..
', ls=9600, tdp = PRINTER_WITHOUT_VFU data_parity = '//parity o=$fname(first_file)
      IFEND
      EXIT configure_lines_loop
    ELSE

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

    IFEND
  LOOPEND configure_lines_loop

  copy_file i=$fname($value(di_procedure_file)) o=$fname(second_file) status=ignore_status
  copy_file i=$fname(first_file) o=$fname($value(di_procedure_file)) status=ignore_status
  copy_file i=$fname(second_file) o=$fname($value(di_procedure_file)//'.$eoi') status=ignore_status
  detach_file $fname(first_file) status=ignore_status
  detach_file $fname(second_file) status=ignore_status

PROCEND configure_lines
