Opening a COM port in QBasic on Windows 7

2019-08-15 04:03发布

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.

3条回答
叛逆
2楼-- · 2019-08-15 04:30

"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.

查看更多
叛逆
3楼-- · 2019-08-15 04:45

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.

查看更多
仙女界的扛把子
4楼-- · 2019-08-15 04:48

The following works FreeBasic

Open Com "COM1:9600,N,8,1" As 1

I recommend the FreeBasic IDE FBIde.

查看更多
登录 后发表回答