/*	M500 : Button and check box, COM transmission	*/
function main()
{
	/*	Button / check box display	*/
	_BtnOpen	 (0, "Send");
	_BtnOpen	 (1, "End");

	_ChkBoxOpen  (0, "Add L/F");
	_ChkBoxSetSts(0, _TRUE);

	/*	COM port generation, open		*/
	_ComCreate(4);
	_ComOpen  (4, 115200, 8, 0, 1);

	_Cls();
	_PrintF("Press the 'Send' button to send the text at the current time.\n");
	_PrintF("Press the 'End' button to end the macro.\n");

	_Stop();

	/*	Resource destruction					*/
	_BtnClose(0); _BtnClose(1); _ChkBoxClose(0);
	_ComClose(4); _ComDelete(4);
}


function _OnButton(BtnNo)
{
	if		(BtnNo == 0) {
		_ComSendText(4, $_DateAndTime());
		if (_ChkBoxGetSts(0)) _ComSendText(4, $_LF);
	}
	else if (BtnNo == 1) _Restart();
}
