(* DELPHI D3 DCC32 -cc *) program DirsList ; uses {Dos} SysUtils ; procedure Q(const P : string) ; var SR : TSearchRec ; Found : integer ; begin Writeln(P) ; Found := FindFirst(P+'*.*', faAnyFile, SR) ; while Found=0 do begin { Writeln('*** ', SR.Name) ; } with SR do if ((Attr and faDirectory)>0) and (Name[1]<>'.') then Q(P+Name+'\') ; Found := FindNext(SR) end {=0} ; FindClose(SR) ; end {Q} ; var PE : ShortString ; begin Write('www.merlyn.demon.co.uk >= 1999-07-29'^M^J, 'D3 DirsList from ', ParamStr(1), ' => ') ; PE := ExpandFileName(ParamStr(1)) ; if PE='' then PE := '.' ; if PE[Length(PE)]<>'\' then PE := PE+'\' { Pity } ; Q(PE) ; Writeln('** Done') end. (* PASCAL OK : program ListDirs ; uses Dos ; procedure Q(const P : PathStr) ; var SR : SearchRec ; begin Writeln(P) ; FindFirst(P+'*.*', AnyFile, SR) ; while DosError=0 do begin { Writeln('*** ', SR.Name) ; } with SR do if ((Attr and Directory)>0) and (Name[1]<>'.') then Q(P+Name+'\') ; FindNext(SR) end {=0} ; end {Q} ; var PE : PathStr ; begin Write('TP/BP ListDirs from ', ParamStr(1), ' => ') ; PE := FExpand(ParamStr(1)) ; if PE[Length(PE)]<>'\' then PE := PE+'\' { Pity } ; Q(PE) ; Writeln('** Done') end. *) (* To recursively visit parent directories it is necessary firstly to comment out the [1], secondly to arrange that it does not try to recurse up where it's just come down from, and maybe thirdly to prevent it from seeking an ancestor of the root directory. These details are left as an exercise for the user; I have solved them in the past. *)