%%HP: T(3)A(D)F(.);
\<< ":01s" 13 CHR + ":01s" 13 CHR 10 CHR + + "" "0" "" "NONE" "" "" "" "" "" "" 0 0 0 0 0 0 0 0 "" ""
\-> Comm1 ANSS MSType PKT ID LASTERROR DLIST FNAME Xc Yc Zc Rc MCOUNT FREEMEM KEYP BUFL ITEMM ERRN FEXIST IDCONT TIMEX ST
	\<<
	CLLCD "Data Collector" 1 DISP 
	MEM 'FREEMEM' STO
	DO
		"     CHOOSE" { { MEASURE 1 } { QUIT 2 } { SERVER 3 } } 1 CLLCD
		CHOOSE DROP 'ITEMM' STO

		CASE 
			ITEMM 1 ==
			THEN
				9600 BAUD 0 PARITY OPENIO 
				BUFLEN DROP SRECV DROP DROP 440 .03 BEEP
				DO
					"Enter filename" "" INPUT "'" SWAP + 
					"'" + OBJ\-> 'FNAME' STO
					VARS 'DLIST' STO
					0 'FEXIST' STO
					DO
						DLIST HEAD 
						FNAME SAME 'FEXIST' STO
						DLIST TAIL 'DLIST' STO
					UNTIL
						DLIST { } == FEXIST 1 == 
						OR
					END
					IF
						FEXIST 1 ==
					THEN
						1320 .05 BEEP 
						"FILE EXIST" MSGBOX
					ELSE
						1320 .05 BEEP
					END
				UNTIL
					FEXIST 0 ==
				END
				"" FNAME STO CLLCD
				TIME \->STR 1 5 SUB " " + DATE \->STR +
				'TIMEX' STO 
				"File started at " FNAME STO+
				FNAME TIMEX 10 CHR + STO+

				DO
					"MEM " FREEMEM \->STR + " PNT " + 
					MCOUNT \->STR + 1 DISP
					DO
					UNTIL
						BUFLEN DROP 'BUFL' STO
						BUFL 0 > KEY
						\-> K
						\<<
							IF
								'K==1'
							THEN
								'KEYP' STO 1 
							ELSE 
								0 'KEYP' STO 0
							END
						\>> 
						OR
					END

					CASE
						BUFL 0 >
						THEN
							BUFLEN DROP SRECV DROP 'ST' STO
							IF
								ST "!01" POS 0 >
							THEN 
								TIME \->STR 1 5 SUB 'TIMEX' STO
								ST ST "!01" POS 4 + ST SIZE SUB 'ST' STO
								ST 1 ST 13 CHR POS 1 - SUB 'ST' STO
								ST 3 DISP 
								ST 1 ST " " POS 1 - SUB 'Xc' STO 
								ST ST " " POS 1 + ST SIZE SUB 'Yc' STO 
								Xc 9 CHR + Yc + 9 CHR + TIMEX + 13 CHR + 10 CHR + 
								FNAME EVAL
								SWAP + FNAME STO
								440 .05 BEEP 
								MCOUNT 1 + 'MCOUNT' STO
								MEM 'FREEMEM' STO
								"m1 = " Xc + "   " + 4 DISP
								"m2 = " Yc + "   " + 5 DISP
								BUFLEN DROP SRECV DROP DROP
							ELSE
								"ERROR! BUFSIZE " BUFL \->STR + 1 DISP
								BUFLEN DROP SRECV DROP DROP
								440 .03 BEEP 880 .03 BEEP 1320 .03 BEEP 
								"" 1 DISP
							END
						END

						KEYP 11 ==
						THEN
							440 .05 BEEP Comm1 XMIT DROP
						END
					END
				UNTIL
					KEYP 16 ==
				END
		        END

			ITEMM 3 ==
		        THEN
				OPENIO BUFLEN DROP SRECV DROP DROP 440 .03 BEEP CLLCD
				"SERVER MODE" 1 DISP
				9600 BAUD 0 PARITY 
				SERVER
		        END
		END
	UNTIL
		ITEMM 2 ==
	END 
	9600 BAUD 0 PARITY
	\>>
\>>
