//	M120 : Display chart chart of trigonometric function
option double;

define	fEnd = _FALSE;

//------------------------------------------------------------------------------//
//	Display chart chart of trigonometric function								//
//																				//
//	Return	:	None															//
//------------------------------------------------------------------------------//
function main()
{
	define	t;
	define	dat[8];

	_Cls();
	_Print("Display chart chart of trigonometric function.\n");
	_Print("Cut the value of tan from -5.0 to + 5.0.\n");
	_Print("Closing the chart window ends the execution of the macro.\n");

	_TmcOpen("Trigonometric function chart diagram", "P: B=10000");
	_TmcWndMove(200,100);
	_TmcWndSize(500,300);
	_TmcClear();
	_TmcSetItems(3);
	_TmcSetRange(-5.1, +5.1);

	t = 0;
	while (!fEnd) {
		dat[0] = _Sin(t);
		dat[1] = _Cos(t);
		dat[2] = _Tan(t);
		if (_Abs(dat[2]) >= 5) {
			dat[2] = _Max(dat[2], -5);
			dat[2] = _Min(dat[2], +5);
		}
		_TmcPutData(dat[]);
		t++;
		_msWait(10);
	}
	_TmcClose();

}
//------------------------------------------------------------------------------//
//	Processing when chart window is closed										//
//																				//
//	Argument:	None					 										//
//																				//
//	Return	:	None															//
//------------------------------------------------------------------------------//
function _OnTmcClose()
{
	fEnd = _TRUE;
}
