Hello wingbar,
The programmer accessed the serial port via this line:
Code:
Open "COM" + p$ + ":9600,N,8,1,CS0,CD0,DS0" For Random As #1 Len = 1
All this line does is Open the COM port for random input and output (print and input just like a text file). p$ is the port number that the users sets.
------------------------------------------------------------------------------
Data is written to the device via this line of code:
Code:
Print #1, Chr$(Val("&h" + a$));
This line prints the the com port. Note that the syntax for the Print # is the same as for standard text files.
------------------------------------------------------------------------------
The programmer used the following line to input the data:
Code:
150 a$ = Hex$(Asc(Input$(1, #1)))
All this does it receive 1 character and hex it.
------------------------------------------------------------------------------
Remember you must close the com port after you are finished with it:
------------------------------------------------------------------------------
Qbasic's accessing of the com port is simple and very easy to work with. I remember back when I was 11. I made a simple BBS with the phone line in my house. It allowed me to control stuff in my room (a fan and a light.) Of course now in days all this sort of stuff is being put into microcontrolers with ethernet and internet accses.
Hope this helps,
Harrison