PROC convert_menu_ve, convmv (
  status : var of status = $optional
  )


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

"     The purpose of this request is to complete site conversion of MENU/VE from
"an applications product to a VE product.  This involves removing the MENU/VE
"catalogs and command procedures from the applications environment.
"     This procedure is called by the BASE_3 installer procedure, after the
"MENU/VE files have been installed into their new catalog on VE.  If
"APP$COMMAND_LIBRARY is empty after removing the MENU/VE command procedures it is
"deleted.
*IFEND

  create_variable applications_catalog k=string v='$system.applications'

  create_variable app$command_library k=string v=applications_catalog//'.app$command_library'
  create_variable name=(proc_status, local_status, ignore_status) k=status
  create_variable modified_library k=boolean v=false
  create_variable remove_commands k=string v='$local.'//$unique

  EXIT_PROC WHEN NOT $file($fname(app$command_library), permanent)

COLLECT_TEXT o=$fname(remove_commands) until='END_COLLECT'

  PUSH file_connections

  delete_file_connection sf=$errors f=$local.output status=ignore_status

  CREATE_OBJECT_LIBRARY

  remove_block: ..
    BLOCK

      add_module l=$fname(app$command_library)

      delete_module m=select_family_admin_menu status=local_status
      IF local_status.normal THEN
        modified_library = true
      ELSEIF $condition(local_status.condition) <> 'OCE$E_SOME_MODULES_NOT' THEN
        EXIT remove_block
      IFEND

      delete_module m=select_main_menu status=local_status
      IF local_status.normal THEN
        modified_library = true
      ELSEIF $condition(local_status.condition) <> 'OCE$E_SOME_MODULES_NOT' THEN
        EXIT remove_block
      IFEND

      delete_module m=select_operators_menu status=local_status
      IF local_status.normal THEN
        modified_library = true
      ELSEIF $condition(local_status.condition) <> 'OCE$E_SOME_MODULES_NOT' THEN
        EXIT remove_block
      IFEND

      delete_module m=select_user_menu status=local_status
      IF local_status.normal THEN
        modified_library = true
      ELSEIF $condition(local_status.condition) <> 'OCE$E_SOME_MODULES_NOT' THEN
        EXIT remove_block
      IFEND

      local_status.normal = true

      EXIT remove_block WHEN NOT modified_library

      display_new_library o=$null status=local_status
      EXIT remove_block WHEN NOT local_status.normal

      generate_library l=$fname(app$command_library//'.$next')

    BLOCKEND remove_block

  QUIT

  IF (NOT local_status.normal) AND ($condition(local_status.condition) = 'OCE$W_NO_MODULES_ON_CURRENT_LIB') ..
        THEN
    local_status.normal = true
    delete_command_list_entry entry=$fname(app$command_library) status=ignore_status
    WHILE local_status.normal DO
      delete_file f=$fname(app$command_library//'.$low') status=local_status
    WHILEND
    local_status.normal = true
  IFEND

  IF local_status.normal THEN
    TASK ring=3
      $system.osf$builtin_library.delete_catalog_contents c=$fname(applications_catalog//'.ease_of_use') ..
            status=ignore_status
      delete_catalog c=$fname(applications_catalog//'.ease_of_use') status=ignore_status
      $system.osf$builtin_library.delete_catalog_contents ..
            c=$fname(applications_catalog//'.family_administration') status=ignore_status
      delete_catalog c=$fname(applications_catalog//'.family_administration') status=ignore_status
      $system.osf$builtin_library.delete_catalog_contents c=$fname(applications_catalog//'.operators_menu') ..
            status=ignore_status
      delete_catalog c=$fname(applications_catalog//'.operators_menu') status=ignore_status
    TASKEND
  IFEND

END_COLLECT

  include_file $fname(remove_commands) status=proc_status
  delete_file $fname(remove_commands) status=ignore_status
  IF proc_status.normal THEN
    proc_status = local_status
  IFEND

  EXIT_PROC WITH proc_status WHEN NOT proc_status.normal

PROCEND convert_menu_ve
