PROCEDURE  prompt_for_system_id (
  device_type : key di,ica2, keyend = $required
  system_id : (var) string = $required
  status: (var) status = $optional
  )

  create_variable input_string k=string
  create_variable integer_number k=integer
  create_variable maximum_sys_id_range k=string
  create_variable minimum_sys_id_range k=string
  create_variable conversion_status k=status

system_id_loop: ..
  LOOP
    IF $string(device_type) = 'DI' THEN
      minimum_sys_id_range = '100000'
      maximum_sys_id_range = '0ffffff'
      put_line  '0Enter last 6 digits of DI system identifier or ? for help:'
      accept_line input_string input p=''
    ELSE
      minimum_sys_id_range = '400101'
      maximum_sys_id_range = '4fffff'
      put_line '0Enter last 6 digits of ICA-II system identifier or ? for help: '
      accept_line input_string input p=''
    IFEND
    IF input_string = '?' THEN
      put_line ('0Supply the last six digits of the 12-digit system identifier.')
      IF $string(device_type) = 'DI' THEN
        put_line (' The system identifier can be found on a plastic tag inside the door' ..
            ' of the DI cabinet.  Note that a 4-digit hexadecimal checksum is appended'..
            ' to the end of the system identifier on the tag; do not enter the checksum ' ..
            ' as part of the identifier.  Also, do not include the radix (16) with the'..
            ' system identifier.', '  ')
      ELSE
        put_line (' The system identifier should be obtained from the customer engineer.'..
            ' Also, do not include the radix (16) with the system identifier.')
      IFEND
    ELSEIF input_string = ' ' THEN
      EXIT system_id_loop
    ELSE
      include_line 'integer_number=$integer(''0''//input_string//''(16)'')' status=conversion_status
      IF conversion_status.normal THEN
          IF (integer_number >= $integer(minimum_sys_id_range//'(16)')) AND ..
             (integer_number <= $integer(maximum_sys_id_range//'(16)')) THEN
            $value(system_id) = '080025' // $translate(lower_to_upper, input_string)
            EXIT system_id_loop
          ELSE
            put_line ('0System identifier out of range, please correct.'..
                 ' System identifier must be in range '//minimum_sys_id_range//'(16) - '//maximum_sys_id_range//'(16).')
          IFEND
        ELSE
          put_line ('0Invalid system identifier, please correct.', '  ')
        IFEND
    IFEND
  LOOPEND system_id_loop

PROCEND prompt_for_system_id
