×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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

(OP)
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
    Do
      Line Input #1, A$
      ArraySize = ArraySize + 1
    Loop Until EOF(1)
  Close
  Redim MyArray$(ArraySize)
  Open "C:\MyTmpDir.tmp" for Output As #1
    For N = 1 to ArraySize
      Line Input #1, MyArray$(N)
    Next
  Close

Have Fun, Be Young... Code BASIC
-Josh

http://cubee.topcities.com

RE: Files Command

CubeE101,
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
   DO
   LINE INPUT #1, A$
      ArraySize = ArraySize + 1
   LOOP UNTIL EOF(1)
   CLOSE
   REDIM MyArray$(ArraySize)
   OPEN "C:\MyTmpDir.tmp" FOR INPUT AS #1
   FOR N = 1 TO ArraySize
      LINE INPUT #1, MyArray$(N)
   NEXT
   CLOSE
   PRINT "Directory for "; path$; " (*.txt)"
   PRINT "Number of files: "; ArraySize
   FOR N = 1 TO ArraySize
      PRINT MyArray$(N)
   NEXT

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
-Josh

http://cubee.topcities.com

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