Article View: alt.lang.basic
Article #57Re: storing directory into an array
From: Peter Kittel
Date: Wed, 08 Apr 1992 09:28
Date: Wed, 08 Apr 1992 09:28
36 lines
1795 bytes
1795 bytes
dryan@cc.uow.edu.au (David Ryan) writes:
> I was wondering if it were possible to shell
>out to dos, do a directory listing, but then store that listing into an
>array so that I may have my way with the elements.
Yes, do something like this:
SHELL "DIR xxx >TEMP"
OPEN "TEMP" FOR INPUT AS 1
n=-1:REM First pass: count lines
WHILE NOT EOF(1)
LINE INPUT#1,a$:n=n+1
WEND
CLOSE 1
DIM d$(n)
OPEN "TEMP" FOR INPUT AS 1
FOR i=0 TO n
LINE INPUT#1,d$(i)
NEXT
CLOSE 1
KILL "TEMP":REM Clean up!
The only problem is when you're going to interpret the contents.
The Dir comes with several lines of heading, the number being different
for different DOS versions. Also at the end you get one or more extra
lines. And until now I didn't find a foolproof method to determine whether
a line is a line with an entry (file or subdir) or belongs to heading or
footing. You see, you *can't* use the date or time for this, as there
exist entries withouth these at all (don't know whether this is a sort
of corruption, but it exists). This part is a whole mess. I just
hardcoded the numbers of head and footlines into my program.
--
Best regards, Dr. Peter Kittel // E-Mail to \\ Only my personal opinions...
Commodore Frankfurt, Germany \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk
Technical Details
Message-ID:
<1992Apr08.092847.12176@public.sub.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!mips!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!smurf.sub.org!public!peterkReferences:
<1992Apr3.062548.7308@cc.uow.edu.au>Show Full Headers
Complete Article Headers
Newsgroups: alt.lang.basic Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!mips!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!smurf.sub.org!public!peterk From: peterk@public.sub.org (Peter Kittel) Subject: Re: storing directory into an array Organization: Public News & Mailserver, Commodore Germany PM UNIX, Frankfurt Date: Wed, 08 Apr 92 09:28:47 GMT Message-ID: <1992Apr08.092847.12176@public.sub.org> References: <1992Apr3.062548.7308@cc.uow.edu.au> Lines: 36