07-19-2004, 11:50 PM
How can I display the results of the following command in QB?
Code:
SHELL("C:\ dir")
SHELL --> dir
|
07-19-2004, 11:50 PM
How can I display the results of the following command in QB?
Code: SHELL("C:\ dir")
07-20-2004, 12:39 AM
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.
07-20-2004, 03:29 AM
Yeah that's what I mean:
Code: dir c:\ >output.txt
07-21-2004, 02:19 AM
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]
07-21-2004, 07:21 PM
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?
07-21-2004, 07:44 PM
Quote:Yeah that's what I mean:Yes. The ">" character redirects standard output to a file, in this case "output.txt". |
« Next Oldest | Next Newest »
|