?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE SCL Interpreter : Return Command' ??
MODULE clm$return_command;

{
{ PURPOSE:
{   This module contains the processor for the return command.
{

?? NEWTITLE := 'Global Declarations', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc clt$parameter_list
*copyc ost$status
?? POP ??
*copyc fsp$detach_file
*copyc clp$evaluate_parameters

?? TITLE := 'clp$_detach_file', EJECT ??

  PROCEDURE [XDCL] clp$_detach_file
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE (osm$detf) detach_file, detach_files, detf (
{   files, file, f: list of file = $required
{   unload_volume, uv: (BY_NAME, ADVANCED) boolean = true
{   status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 6] of clt$pdt_parameter_name,
      parameters: array [1 .. 3] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$list_type_qualifier_v2,
        element_type_spec: record
          header: clt$type_specification_header,
        recend,
      recend,
      type2: record
        header: clt$type_specification_header,
        default_value: string (4),
      recend,
      type3: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [91, 7, 22, 11, 41, 55, 190],
    clc$command, 6, 3, 1, 1, 0, 0, 3, 'OSM$DETF'], [
    ['F                              ',clc$abbreviation_entry, 1],
    ['FILE                           ',clc$alias_entry, 1],
    ['FILES                          ',clc$nominal_entry, 1],
    ['STATUS                         ',clc$nominal_entry, 3],
    ['UNLOAD_VOLUME                  ',clc$nominal_entry, 2],
    ['UV                             ',clc$abbreviation_entry, 2]],
    [
{ PARAMETER 1
    [3, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 19, clc$required_parameter,
  0, 0],
{ PARAMETER 2
    [5, clc$advanced_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_default_parameter, 0, 4],
{ PARAMETER 3
    [4, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_parameter, 0, 0]],
{ PARAMETER 1
    [[1, 0, clc$list_type], [3, 1, clc$max_list_size, 0, FALSE, FALSE],
      [[1, 0, clc$file_type]]
    ],
{ PARAMETER 2
    [[1, 0, clc$boolean_type],
    'true'],
{ PARAMETER 3
    [[1, 0, clc$status_type]]];

?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$files = 1,
      p$unload_volume = 2,
      p$status = 3;

    VAR
      pvt: array [1 .. 3] of clt$parameter_value;

    VAR
      detachment_options: ^fst$detachment_options,
      file_list: ^clt$data_value;

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    IF pvt [p$unload_volume].value^.boolean_value.value THEN
      detachment_options := NIL;
    ELSE
      PUSH detachment_options: [1 .. 1];
      detachment_options^ [1].selector := fsc$do_unload_volume;
      detachment_options^ [1].unload_volume := FALSE;
    IFEND;

    file_list := pvt [p$files].value;
    WHILE file_list <> NIL DO
      fsp$detach_file (file_list^.element_value^.file_value^, detachment_options, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      file_list := file_list^.link;
    WHILEND;

  PROCEND clp$_detach_file;

MODEND clm$return_command;
