: RETALL:     A script to return all files on the specified device
: i. e. RETALL /H0
: Author:   Stefan Maetje /STM for esd GmbH, 30165 Hannover, Germany
: Version:  0.1
: Date:     21-07-1998
: Version:  0.2
: Date:     30-07-1998  Bugfix for drives with no files open. --NONE--
:           27-05-1999  (I HASSINE):'-?'displays the correct usage of RETALL
: -------------------------------------------------------------------
IF TEST $# -NE 1; THEN
  ECHO 'RETALL: A script to return all files on the specified device';
  ECHO 'USAGE:  RETALL /H0';
  EXIT(0);
FI;
IF TEST $1 = '-?'
THEN
  ECHO 'RETALL : a script to return all files on the specified device'
  ECHO 'i. e. RETALL /H0'
  EXIT(0)
FI;
OpenFiles=`FILES $1`;
IF TEST -Z $OpenFiles; THEN
  ECHO "Error on device $1";
  ECHO "Abort!";
  EXIT(0);
FI;
Line=1; : Init line counter to first line
FOR Zeile IN -L $OpenFiles; DO
  SET $Zeile; : get position paras
  :  ECHO $@;   : DEBUG
  CASE $Line IN
  1 )
    DRV=$4; : QUICK HACK!!
    Line=2;
    CONT;;  : to start of FOR $Zeile
  2 ) : Nothing to do, if NONE or MOUNTED found.
    Line=3;
    IF TEST $1='--NONE--' -O $1='--MOUNTED--'; THEN
      NoClose=1;
      BREAK;
    FI;;
  * );;
  ESAC;
  : Test if its a file name.
  IF TEST SEG[LEN($1),]($1)!='/'; THEN : It is a file.
    : ECHO "File: " $@; : DEBUG
    CMD="RETURN -A ${DRV}$1";
    IF TEST SEG[1,1]($2)='.'; THEN : ADD THE EXTENSION
      CMD=${CMD}$2;
    FI;
    ECHO $CMD;  : Echo the file to return.
    EXEC $CMD;  : Now return the file.
  FI;
DONE; : FOR Zeile ...
: ECHO $OpenFiles; : DEBUG
IF TEST -Z $NoClose; THEN
  ECHO ">>${$}: All done.";
ELSE
  ECHO ">>${$}: Nothing to return!";
FI;
EXIT(0);
