PROCEDURE (HIDDEN) qcp$convert_configuration (
  prolog_file, pf: file = $required
  new_prolog_library, npl: file = $required
  old_prolog_library, opl: file = $optional
  status)

"$FORMAT=OFF
VAR
ignore_status:status
new_library: file =new_prolog_library
VAREND

"$FORMAT=ON

COLLECT_TEXT $local.create_prolog_file until='end_crepf'
PROCEDURE (HIDDEN) cmp$create_prolog (
  prolog_name, pn: name = $name($mainframe(identifier))
  file, f: key
      (lcu_mainframe_subcommands, lms)
      (lcu_network_subcommands, lns)
      (pcu_subcommands, ps)
    keyend = $required
  until, u: string = '**'
  input, i: file = cmd$crep_input, $command
  output, o: file = cmd$crep_output,
    $system.site_os_maintenance.deadstart_commands.prolog_library
  output_format, of: key
      (command_library, cl)
      (source_library, sl)
    keyend = cmd$crep_output_format, command_library
  deck_prefix, dp: name 1..12 = cmd$crep_deck_prefix, none
  modification_name: name = cmd$crep_modification, $name($job(user))
  status)

"$format=off
var
   converted_prolog : file =$local.temp_prolog_file
   ignore_status :status
   key: name
   status: status
   work_file:file
varend

"$format=on

  IF prolog_name = none THEN
    EXIT_PROC WITH $status(false, 'US', 001, ..
          ' The name NONE is an unacceptable name for a prolog.')
  IFEND

  PUSH command_list
  create_command_list_entry $local status=ignore_status
  PUSH file_connections

COLLECT_TEXT converted_prolog sm='~' until='end of proc'
PROCEDURE ~prolog_name~ (
  status)

COLLECT_TEXT $local.pcu_subcommands until='end_prolog_file'
end_prolog_file
COLLECT_TEXT $local.lcu_mainframe_subcommands until='end_prolog_file'
end_prolog_file
COLLECT_TEXT $local.lcu_network_subcommands until='end_prolog_file'
end_prolog_file

PROCEND ~prolog_name~
end of proc

  delete_file $local.lcu_mainframe_subcommands status=ignore_status
  delete_file $local.lcu_network_subcommands status=ignore_status
  delete_file $local.pcu_subcommands status=ignore_status

  IF (output_format = command_library) OR (output_format = cl) THEN
    CREATE_OBJECT_LIBRARY
      delete_file_connection $errors $local.output status=ignore_status
      add_module m=prolog_name l=output status=status
      IF status.normal THEN
        generate_library format=scl_proc library=$local.cmf$crep_temp
        $local.cmf$crep_temp
      IFEND
    QUIT
  ELSE "source_library"
    deck = $name($string(deck_prefix)//$string(prolog_name))
    SOURCE_CODE_UTILITY
      use_library output status=status
      IF status.normal THEN
        IF $deck(deck) THEN
          extract_deck deck source=$local.cmf$crep_temp status=status
          IF status.normal THEN
            include_command '$local.cmf$crep_temp' status=ignore_status
          IFEND
        IFEND
      IFEND
    QUIT
  IFEND

  key = $name($string(file))
"$format=off
  IF $file($local//key, size) = 0 THEN
    work_file = $local//key
  ELSE
COLLECT_TEXT $output sm='?'
  FIle ?file? ignored - already defined in prolog ?prolog_name?.
**
    work_file = $null
  IFEND
"$format=on

  include_line ..
        'collect_text input=input output=work_file until='//$quote(until)

  EDIT_FILE converted_prolog p=$null o=$null
    create_variable status k=status
    locate_text 'COLLECT_TEXT $local.pcu_subcommands' status=status
    IF status.normal THEN
      read_file $local.pcu_subcommands p=after status=ignore_status
    IFEND

    locate_text 'COLLECT_TEXT $local.lcu_mainframe_subcommands' status=status
    IF status.normal THEN
      read_file $local.lcu_mainframe_subcommands p=after status=ignore_status
    IFEND

    locate_text 'COLLECT_TEXT $local.lcu_network_subcommands' status=status
    IF status.normal THEN
      read_file $local.lcu_network_subcommands p=after status=ignore_status
    IFEND
  QUIT

  IF (output_format = command_library) OR (output_format = cl) THEN
    CREATE_OBJECT_LIBRARY
      combine_module l=output status=ignore_status
      combine_module library=converted_prolog
      generate_library library=output
    QUIT
  ELSE "source_library"
    SOURCE_CODE_UTILITY
      IF $file(output, opened) THEN
        use_library output
      ELSE
        create_library result=output
      IFEND

      IF NOT $modification(modification_name) THEN
        create_modification modification_name status=ignore_status
      IFEND
      IF NOT $deck(deck) THEN
        create_deck deck=deck modification=modification_name
      IFEND
      EDIT_DECK deck=deck modification=modification_name p=$null o=$null
        delete_lines l=all status=ignore_status
        read_file file=converted_prolog p=b
      END
    QUIT
  IFEND

  delete_file converted_prolog status=ignore_status
  delete_file $local.lcu_mainframe_subcommands status=ignore_status
  delete_file $local.lcu_network_subcommands status=ignore_status
  delete_file $local.pcu_subcommands status=ignore_status
  delete_file $local.cmf$crep_temp status=ignore_status

PROCEND cmp$create_prolog
end_crepf

  delete_variable cmd$crep_input status=ignore_status
  create_default_variable name=cmd$crep_input default='$command_of_caller'

  delete_variable cmd$crep_output status=ignore_status
  create_default_variable name=cmd$crep_output default=$string(new_library)

  IF $specified(old_prolog_library) THEN
    CREATE_OBJECT_LIBRARY
      add_module old_prolog_library status=ignore_status
      combine_module new_library status=ignore_status
      generate_library new_library status=ignore_status
    QUIT
  IFEND

  include_file prolog_file

  delete_variable cmd$crep_input status=ignore_status
  delete_variable cmd$crep_output status=ignore_status

PROCEND qcp$convert_configuration
