Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Files Command

Files Command

Files Command

Is there a way to get the names of files and directories into an array listed by the command Files ?

RE: Files Command

I think there is a hack, but I can't remember off the top of my head...

for a quick workaround... 'pipe' the output to a text file...

Normal Use:
  Dir *.txt

Pipe to 'C:\MyTmpDir.tmp' use:
  Dir *.txt<C:\MyTmpDir.tmp

To use this in QB...
  Shell "Dir " + Path$ + "*.txt<C:\MyTmpDir.tmp"
  ArraySize = 0
  Open "C:\MyTmpDir.tmp" for Output As #1
      Line Input #1, A$
      ArraySize = ArraySize + 1
    Loop Until EOF(1)
  Redim MyArray$(ArraySize)
  Open "C:\MyTmpDir.tmp" for Output As #1
    For N = 1 to ArraySize
      Line Input #1, MyArray$(N)

Have Fun, Be Young... Code BASIC


RE: Files Command

I'm afraid to pipe output you should use ">" instead...
Ok,I tried that program in QBasic - one more thing: one need open for Input.
So, it goes like this:

   path$ = "c:\"
   SHELL "Dir " + path$ + "*.txt /b>C:\MyTmpDir.tmp"
   ASize = 0
   OPEN "C:\MyTmpDir.tmp" FOR INPUT AS #1
   LINE INPUT #1, A$
      ArraySize = ArraySize + 1
   REDIM MyArray$(ArraySize)
   OPEN "C:\MyTmpDir.tmp" FOR INPUT AS #1
   FOR N = 1 TO ArraySize
      LINE INPUT #1, MyArray$(N)
   PRINT "Directory for "; path$; " (*.txt)"
   PRINT "Number of files: "; ArraySize
   FOR N = 1 TO ArraySize
      PRINT MyArray$(N)

RE: Files Command

That's right...

< pipes the text into the program...

> pipes the text to a file...

Thanks, i used to always use a program where you had to use the < pipe, so my mind associates pipe with <...

Sorry for the typo on the input also, thanks for the corrections

(I think I must have been Output Dyslexically Challenged (ODC) yesterday)

Have Fun, Be Young... Code BASIC


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close