home *** CD-ROM | disk | FTP | other *** search
- /* Directory Lister
- This REXX script will list all of the files in
- a directory from where you are to the deepest
- subdirectory. I wrote it primarily to give me a
- tool by which I get a directory HC to store with
- each disk. The only arguments that the program takes is
-
- FILENAME The filename to which the output should be sent
- defaults to printing to the console (Say command)
-
- Author Michael E. Stamps
- Program Type: FreeBie Ware
- Blame: The author accepts no responsibilty for anything
- this program does. He also does not accept responsiblity
- for the depletion of the ozone layer and a multitude of
- other things.
- Documentation: This is it.
- */
-
- arg FILENAME
-
- null = addlib('rexxsupport.library',0,-30,0)
- null = addlib('rexxmathlib.library',0,-30,0)
- null = addlib('rexxarplib.library',0,-30,0)
-
- If FILENAME ~= "" Then
- do
- check = open("output",Filename,"write")
- If check ~= 1 Then
- Do
- Say Filename' Cannot be opened for output'
- Exit
- End
- EndIf
- end
- EndIf
-
- If FileName = "" Then
- null = WriteDirs1(0)
- Else
- null = WriteDirs2(0)
- exit /* end of program */
-
- /*===============================================================*/
- WriteDirs1: Procedure Expose MAXLEVELS
- arg Depth
-
- spacer = copies(" ",depth)
- numdirs = FileList("*" , Dirs ,"D")
- numfiles = FileList("*" , Files ,"F")
-
- CurrDirectory =
-
- do i = 1 to numfiles
- Say spacer''files.i
- end
-
- if numdirs > 0 Then
- do i = 1 to numdirs
- say ""
- say spacer'<'Dirs.i'>'
- null = Pragma('Directory',dirs.i)
- null = WriteDirs1(Depth + 1)
- null = Pragma('Directory','/')
- end /* i */
-
- return Files.
-
- /* ================================================================= */
-
-
- WriteDirs2: Procedure Expose MAXLEVELS
- arg Depth
-
- spacer = copies(" ",depth)
- numdirs = FileList("*" , Dirs ,"D")
- numfiles = FileList("*" , Files ,"F")
-
- CurrDirectory =
-
- do i = 1 to numfiles
- null = writeln("output",spacer''files.i)
- end
-
- if numdirs > 0 Then
- do i = 1 to numdirs
- null = writeln("output","")
- null = writeln("output",spacer'<'Dirs.i'>')
- null = Pragma('Directory',dirs.i)
- null = WriteDirs2(Depth + 1)
- null = Pragma('Directory','/')
- end /* i */
-
- return Files.
-
- /* ================================================================= */
-