%%HP: T(3)A(D)F(.);
@ RDL Ron's Directory Lister - This should (almost must) be in HOME, STD Mode
@
@   RBJ 4/05/90 Initial Code
@       4/06/90 Local Functions, indentation
@       4/11/90 Better labeling of types, DotSpace indentation
@       4/12/90 List process at start rather than in the middle
@       4/24/90 Use GET from list vs OBJ TO on stack: CORRECT ORDER
@       4/25/90 Revise byte count, type, Use implicit ->STR behavior
@       5/03/90 Display with subdirectory depth as line number, more VTYPEs
@       5/07/90 Cleaned up code slightly
@       5/08/90 Added print control on flag 9
\<< 
  IF DUP TYPE 5 ==                          @ If a list, say from HOME VARS
  THEN DUP SIZE                             @ Length of list
    IF DUP                                  @ If non zero ( > 0)
    THEN 1 SWAP                             @ Set up loop
      FOR j DUP j GET RDL                   @ Copy list, get list(j), 
      NEXT DROP                             @ Drop list when done
    ELSE DROP2                              @ Drop 0 and { }
    END   
  ELSE DUP                                  @ NOT a list, Make a copy
    IF TYPE 6 ==                            @ If a name
      THEN DUP                              @ Copy name for later use
      DUP " " + OVER                        @ 'NAME' "NAME " 'NAME'
      BYTES SWAP DROP CEIL + " " +          @ ROUND UP,'NAME' "NAME bytes "
      SWAP VTYPE CASE                       @ Common object type labels
        DUP  8 == THEN "Prog" END           @ In approx frequency order
        DUP  0 == THEN "Real" END
        DUP 15 == THEN "Dir"  END
        DUP  5 == THEN "List" END
        DUP  2 == THEN "Str"  END
        DUP  9 == THEN "Alg"  END
        DUP 11 == THEN "Grob" END
        "Type " OVER +                      @ Otherwise "Type N"
      END                                   @ "Name bytes "  N "type"
      SWAP DROP +                           @ Drop type number N, append
      ". . . . . . . . . . "                @ Indent with ". " each dir level
      1 PATH SIZE 1 - 2 *                   @ Compute PATH length, string count
      SUB SWAP +                            @ Extract substring and prepend 
      IF 9 FS? THEN PR1 END                 @ Print if Enabled 
      "\010\010" + PATH SIZE DISP           @ Display on calc line, DROP
      DUP VTYPE                             @ Get vtype
      IF 15 ==                              @ If a directory...
      THEN DUP PATH SWAP EVAL               @ Save current path, go into dir
        VARS RDL                            @ Find variables, run RDL
        EVAL                                @ Evaluate prev PATH
      END                                   @ End Directory processing
    END                                     @ End of Type 6 (Name) Processing
    DROP                                    @ Drop Name or other Object
  END                                       @ End of Type 5 (List) Processing
\>>

