/* * TREE displays the directory structure that exists below the * current directory. * * * Get the directory argument */ parse arg Directory . if Directory = "" then Directory = "." /* * Display the directory tree for the directory passed on the command line */ call RecursiveDirectoryDisplay Directory, 0 exit /* * Routine to display the subdirectories for the directory specified */ RecursiveDirectoryDisplay:procedure /* * Get the directory to scan and the amount to indent arguments */ parse arg Directory, Indent /* * List the directory on the external data queue. */ call popen 'ls -l' Directory /* * If there are any entries, skip the first non-file entry */ if queued() = 0 then return pull . /* * Scan the external data queue for directory entries. They begin with 'd'. * If a directory is found, save in the directory table. */ DirectoryCount = 0 do while queued() <> 0 parse pull string parse var string Permissions +1 . if Permissions = 'd' then do NumWords = words(string) Filename = word(string,Numwords) /* last word on line */ DirectoryCount = DirectoryCount + 1 DirectoryTable.DirectoryCount = Filename end end /* * Display each directory indented to this level with a preceeding "+---->". * Then list the directory's contents by calling RecursiveDirectoryDisplay. */ do DirectoryIndex = 1 to DirectoryCount say copies(' ', Indent)'+---->'DirectoryTable.DirectoryIndex call RecursiveDirectoryDisplay Directory'/'DirectoryTable.DirectoryIndex, Indent + 6 end DirectoryIndex return