问题
I'm having difficulty opening a COM port in QBasic (obtained from www.qbasic.net) like so
OPEN "COM4:9600,N,8,1,BIN" FOR OUTPUT AS #1
However when I execute this statement in QBasic the open keyword is highlighted and I get the error message Bad file name
.
回答1:
Is Com4: one of the available serial ports? Look in control panel and make it is one of the available ports. Also, you must make sure no other programs have the port open.
回答2:
The following works FreeBasic
Open Com "COM1:9600,N,8,1" As 1
I recommend the FreeBasic IDE FBIde.
回答3:
"COM4:9600,N,8,1,BIN"
The semantics for opening files changed in Win2K. On NTFS, the colon indicates an Alternate Data Stream, and the DOS use of the colon when opening serial devices was not implemented.
So on Win7, "COM4:9600,N,8,1,BIN" is a bad filename.
来源:https://stackoverflow.com/questions/19317679/opening-a-com-port-in-qbasic-on-windows-7