Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SHELL --> dir
#1
How can I display the results of the following command in QB?

Code:
SHELL("C:\ dir")
Reply
#2
Do you mean:
Code:
SHELL "dir c:\"
?

That displays the results. Or:

dir > output.txt

will write the results of dir to output.txt, and from there you can use it in qbasic. Be careful when using SHELL commands, though - it makes it harder for your programs to work on anything newer than win98.
Reply
#3
Yeah that's what I mean:
Code:
dir c:\ >output.txt
Like this?
Reply
#4
Well, then you have to do something like:

[syntax="qbasic"]f = FREEFILE
open "output.txt" for input as #f
do while not eof(f)
line input #f, s$
print s$
loop
close #f[/syntax]
Reply
#5
Well yeah, but my question was: How do I do this exactly? I know how to open a textfile and write data to it, but how do I write the output of DOS commands to a textfile?
Reply
#6
Quote:Yeah that's what I mean:
Code:
dir c:\ >output.txt
Like this?
Yes. The ">" character redirects standard output to a file, in this case "output.txt".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)