Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!psuvax1!brutus.cs.uiuc.edu!samsung!think!ames!uhccux!webb From: webb@uhccux.uhcc.hawaii.edu (Thomas Webb) Newsgroups: comp.lang.pascal Subject: Rusty programmer seeks help... Summary: Brain rot has taken over Message-ID: <5651@uhccux.uhcc.hawaii.edu> Date: 8 Dec 89 02:40:58 GMT Reply-To: webb@uhccux.UUCP (Thomas Webb) Distribution: usa Organization: University of Hawaii Lines: 62 Hi folks, sorry to bother you with what I think must be a simple porblem, but I'm totally confused. I haven't done any programming since I got out of University, and that was years ago despite what it says on my organisation line, and it seems my mind has been busy obeying the second law of thermodynamics... Anyway, all I am trying to do is write a short program which will give me a list of a directory tree. I am sure that this problem can be easily solved using recursion, but I think that DOS may be getting confused somehow--perhaps the DTA isn't being properly pased to it. I have included the file that I thought would work when I considered the problem--I've tried a bunch of other ways since, but none are doing what I want. Simply stated, the problem with this routine is that it works fine on the way down the first branch of the tree, but fails to find any new branches on the way back up... Thanks in advance for your thoughts, -tom PS I'm using Turbo Pascal 5.5. -tsmw ----------- program treetmp; uses DOS; var dirInfo: SearchRec; nextDirectory:string; procedure tree(next:string); var dtmp:string; begin findFirst(next + '*.*',directory,dirInfo); while dosError=0 do begin if (dirinfo.attr=directory) AND (dirinfo.name > '..') then begin dtmp:=next+dirinfo.name+'\'; writeln(dtmp); tree(dtmp); end; findNext(dirInfo); end; end; begin {MAIN} nextDirectory:='d:\'; writeln(nextDirectory); tree(nextDirectory); end. -- =============================================================================== webb@uhccux.uhcc.Hawaii.edu ===============================================================================