//	M062 : eLXgt@CǂݏoA100ms^s̑xłbnl|[g֑M
option unsigned;

define	fEnd  = _FALSE;
define	count = 0;
define	finp;
define	port = 4;

//------------------------------------------------------------------------------//
//	eLXgt@CǂݏoA100ms^s̑xłbnl|[g֑M				//
//																				//
//	߂l	F	Ȃ															//
//------------------------------------------------------------------------------//
function main()
{
	define	$file, $line;
	define	count;

	_Cls();
	_Print("eLXgt@CǂݏoāA100ms/line ̑x COM", port, " ֑M܂\n");
	_ComCreate(port);									//	bnl|[g
	_Print("\nMt@CIĂ\n");
	if (($file = $_GetOpenFile("M邷t@CIĂ", "Text(*.txt)/*.txt/All(*.*)/*.*", "txt")) != 0) {
		_ComOpen(port, 115200, 8, 0, 1);				//	bnl|[gI[v
		if (finp = _FOpen($file, 'rt')) {				//	t@CI[vCH	
			_Print("Mt@C", $file, "\n");		//		Mt@C\
			_TimerStart(1, 100);						//		^C}N
			_Stop();									//		I҂
			_FClose(finp);								//		t@CN[Y
		}
	}

	_ComClose (port);									//	bnl|[gN[Y
	_ComDelete(port);									//	bnl|[gj
}

//------------------------------------------------------------------------------//
//	^C}Cxg																//
//																				//
//	߂l	F	Ȃ															//
//------------------------------------------------------------------------------//
function _OnTimer(tid)
{
	define	$line;

	if (tid == 1) {										//	^C}PH
		if ($line = $_FGetS(finp)) {					//		t@CsǂݏoH
			_ComSendText(port, $line);					//			PsM
			_Print("line = ", ++count, "\r");			//			Ms\
		}
		else {											//		dneH
			_TimerStop(1);								//			^C}~
			_Restart();									//			I
		}
	}
}
