主题:这几句话如何改成vc语句?
源程序是QBASIC,控制串口,需要改成api语句,不能调用控件!
' Open COM: 4800 Bd, no parity, 8 data bits, 1 stop, no handshake
OPEN "com1:4800,n,8,1,rs,cs,ds,cd" FOR INPUT AS #1
ON ERROR GOTO RecvErr
MainLoop:
DO
WHILE ASC(INPUT$(1, #1)) <> STX: WEND 'wait for STX
sonde = ASC(INPUT$(1, #1)) 'type of detector
bc = sonde
mantlo = ASC(INPUT$(1, #1)) 'low order mantissa
bc = bc XOR mantlo
manthi = ASC(INPUT$(1, #1)) 'high order mantissa
bc = bc XOR manthi
expon = ASC(INPUT$(1, #1)) 'exponent
bc = bc XOR expon
IF expon > 127 THEN expon = expon - 256
bc = bc XOR ASC(INPUT$(1, #1)) 'block check
IF bc <> 0 THEN ERROR DEVERR 'block check error
mant = manthi * 256 + mantlo '16 bit mantissa
xdl = mant * 2 ^ (expon - 15) 'dose rate as floating point number
GOSUB GetProbe 'set ger$, det$ and unit$
PRINT TIME$; " Device: 1145"; ger$; " Detector: "; det$;
PRINT USING " Reading=########.### "; xdl;
PRINT unit$
LOOP WHILE LEN(INKEY$) = 0 'exit on any key
PRINT "End."
END
' Open COM: 4800 Bd, no parity, 8 data bits, 1 stop, no handshake
OPEN "com1:4800,n,8,1,rs,cs,ds,cd" FOR INPUT AS #1
ON ERROR GOTO RecvErr
MainLoop:
DO
WHILE ASC(INPUT$(1, #1)) <> STX: WEND 'wait for STX
sonde = ASC(INPUT$(1, #1)) 'type of detector
bc = sonde
mantlo = ASC(INPUT$(1, #1)) 'low order mantissa
bc = bc XOR mantlo
manthi = ASC(INPUT$(1, #1)) 'high order mantissa
bc = bc XOR manthi
expon = ASC(INPUT$(1, #1)) 'exponent
bc = bc XOR expon
IF expon > 127 THEN expon = expon - 256
bc = bc XOR ASC(INPUT$(1, #1)) 'block check
IF bc <> 0 THEN ERROR DEVERR 'block check error
mant = manthi * 256 + mantlo '16 bit mantissa
xdl = mant * 2 ^ (expon - 15) 'dose rate as floating point number
GOSUB GetProbe 'set ger$, det$ and unit$
PRINT TIME$; " Device: 1145"; ger$; " Detector: "; det$;
PRINT USING " Reading=########.### "; xdl;
PRINT unit$
LOOP WHILE LEN(INKEY$) = 0 'exit on any key
PRINT "End."
END