CLS PRINT " Serial Data Logger." PRINT PRINT " by Tim Nolan copyright 1999 " PRINT LINE INPUT "Enter output file name (example: decitime.txt): "; outfile$ OPEN outfile$ FOR OUTPUT AS #2 'open file for writing PRINT INPUT "Enter number of seconds to skip between each entry: "; decimate PRINT 'get number of lines to skip INPUT "Choose COM1 or COM2 for data input (type 1 or 2): "; comnum PRINT 'select COM1 or COM2 IF (comnum = 2) THEN PRINT "Open COM2 as 9600 and N,8,1 and ignore hardware handshaking." OPEN "COM2:9600,N,8,1,BIN,CD0,CS0,DS0,OP0,RS,TB2048,RB2048" FOR RANDOM AS #1 ELSE PRINT "Open COM1 as 9600 and N,8,1 and ignore hardware handshaking." OPEN "COM1:9600,N,8,1,BIN,CD0,CS0,DS0,OP0,RS,TB2048,RB2048" FOR RANDOM AS #1 END IF 'open COM1 or COM2 for serial input PRINT PRINT "Hit Q to Quit" PRINT count = 0 'intialize line count to zero DO LINE INPUT #1, edata$ 'read in line of data from serial port MID$(edata$, 1) = " " 'write blank to overwrite leading CR edata$ = LTRIM$(edata$) 'get rid of leading blank count = count + 1 'keep track of line number IF (count MOD decimate) = 0 THEN 'if remainder zero then write out line PRINT #2, DATE$; ","; TIME$; ","; edata$ 'to file PRINT DATE$; ","; TIME$; ","; edata$ 'and to the screen END IF qkey$ = INKEY$ 'check for quit key LOOP UNTIL (LCASE$(qkey$) = "q") 'drop out of loop if q is pressed CLOSE #1 'close serial port and writing file CLOSE #2 PRINT "Number of lines in the output file = "; (count / decimate) PRINT "Program finished and files closed"