Hi. Am new to the forum. I've been a QB 4.5 user for many years, using it to control electronic lab instruments via RS-232 to make voltage measurements and log test data. I was very pleased to find QB64 as a modern alternative that can run in Windows 10. I wish to ask for the forum's help to get my test system up and running again.
My original QB4.5 program used OPEN FOR RANDOM for communicating with a digital multimeter. It sends a command to the meter, reads and discards the echo that the meter sends back, then reads the prompt that the meter sends back. See following snippet of the original QB 4.5 program:
MeterSetup:
OPEN "COM2:1200,N,8,,CS,DS,CD" FOR RANDOM AS #11 'open path to Fluke 45
Cmd$ = "REMS;VDC;RANGE 3;RATE M;FORMAT 1"
GOSUB ProgramFluke
ProgramFluke:
PRINT #11, Cmd$
LINE INPUT #11, Result$ 'clears the echo response from meter
Prompt$ = INPUT$(5, #11) 'reads the prompt returned by the meter
RETURN
Running this same program in QB64 causes error "Bad file mode" at PRINT #11, Cmd$ I figured this is because of the description of OPEN COM from the QB64 Wiki: "Currently, QB64 only supports OPEN FOR RANDOM access using the GET/PUT commands in BIN mode." I don't know what BIN mode is, so I tried changing the mode from RANDOM to OUTPUT. However, I realize that it won't be able to read anything from the meter in OUTPUT mode, so I CLOSE the path after sending Cmd$ and try to re-open it in INPUT mode as follows:
MeterSetup:
OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR OUTPUT AS #11 'open path to Fluke 45
Cmd$ = "REMS;VDC;RANGE 3;RATE M;FORMAT 1"
GOSUB ProgramFluke
CLOSE #11
OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR INPUT AS #12 'open path to Fluke 45
LINE INPUT #11, Result$ 'clears the echo response from meter
Prompt$ = INPUT$(5, #11) 'reads the prompt returned by the meter
ProgramFluke:
PRINT #11, Cmd$
RETURN
This succeeds in sending the Cmd$ to the meter which gets set to the desired settings, but I get error message "Bad file name" for the OPEN FOR INPUT statement. Why? The COM port had worked fine as OUTPUT just moments earlier. How can I now read what the meter is sending back?
I'd appreciate any help you can offer. Thanks!