【发布时间】:2015-10-27 01:56:03
【问题描述】:
我想知道如何在 QBasic 中运行批处理文件。
当我的意思是在我的意思是不在新窗口中时。
你能帮帮我吗?
我正在制作一个假的 DOS。
【问题讨论】:
-
据我所知,QBasic 中应该有一个
SHELL命令...
标签: batch-file dos qbasic
我想知道如何在 QBasic 中运行批处理文件。
当我的意思是在我的意思是不在新窗口中时。
你能帮帮我吗?
我正在制作一个假的 DOS。
【问题讨论】:
SHELL 命令...
标签: batch-file dos qbasic
我找不到在同一窗口中专门运行 dos 命令的方法。您可以做的是 SHELL _HIDE "[command] > outputfile.txt" 然后打开该文件并将每一行打印到您的 qb 应用程序。
示例并不完美,但可以作为开始的基础:
RunCommand "dir"
END
SUB RunCommand (enteredCommand$)
IF LEN(enteredCommand$) = 0 THEN EXIT FUNCTION 'no entry
IF LEN(ENVIRON$("OS")) THEN CMD$ = "CMD /C " ELSE CMD$ = "COMMAND /C "
SHELL _HIDE CMD$ + enteredCommand$ + " > output"
OPEN "output" FOR APPEND AS #1 'this may create the file
L% = LOF(1) 'verify that file and data exist
CLOSE #1
IF L% THEN 'read file if it has data
OPEN "output" FOR INPUT AS #1
WHILE NOT EOF(1)
LINE INPUT #1, line$ 'read only line in file
PRINT line$
WEND
CLOSE #1
ELSE
PRINT "Command Not Found" 'returns zero length string if path not found
END IF
KILL "output" 'deleting the file is optional
END FUNCTION
【讨论】: