PROCEDURE activate_qtfs (
  host_physical_identifier, hpi: string 1..31 = $required
  load_map, lm: file = $optional
  account_prefix_character, apc: (BY_NAME, ADVANCED) name 1..1 = A
  project_prefix_character, ppc: (BY_NAME, ADVANCED) name 1..1 = P
  status)


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

"   This request will define and activate the system task for the QTF/VE server application.
*IFEND

  VAR
    load_map_file: file
    load_map_options: name
    local_status: status
    qtf_library: file = $system.ptf_qtf.osf$user_file_transfer
    task_parameters: string 1..512
  VAREND

  IF $first($file_attributes(qtf_library, registered)).registered THEN

    IF $specified(load_map) THEN
      load_map_file = load_map
      load_map_options = all
    ELSE
      load_map_file = $local.$null
      load_map_options = none
    IFEND

    task_parameters = 'host_physical_identifier ='//$quote(host_physical_identifier)
    task_parameters = task_parameters//' account_prefix_character='//account_prefix_character
    task_parameters = task_parameters//' project_prefix_character='//project_prefix_character

    delete_system_task name=queue_transfer_server status=local_status
    IF (NOT local_status.normal) AND local_status.condition <> ose$system_task_not_defined THEN
      EXIT procedure WITH local_status
    IFEND

    define_system_task name=queue_transfer_server library=qtf_library starting_procedure=nfp$qtfs_boot ..
          automatic_restart=false restart_after_idle=true deactivate_task_option=terminate ..
          idle_task_option=terminate load_map=load_map_file load_map_options=load_map_options ..
          termination_error_level=error parameters=task_parameters execution_ring=6 status=local_status

    EXIT procedure WITH local_status WHEN (NOT local_status.normal)

    activate_system_task task_name=queue_transfer_server

  ELSE
    display_value value=$status(false, 'PF', pfe$unknown_permanent_file, $fname(qtf_library))
    put_line lines=('  ', ' --ERROR-- Unable to activate:  QTF is not installed.') output=$response
  IFEND

PROCEND activate_qtfs
