#include<stdio.h>
#include<string.h>
#include<math.h>
#include<egb.h>
#include"strin.h"
#include"value.h"

#define	NOERR	0
#define	ERR		1

char	egbwork[1536];

int		main()
{
	char	str[256];
	double	a;

	EGB_init( egbwork, 1536 );
	EGB_resolution( egbwork, 1, 3 );
	EGB_writePage( egbwork, 1 );

	ST_locate( 0, 0 );
	while(1)
	{
	switch( ST_inputStrings( egbwork, str, 256, "計算式を入力して下さい" ) )
	{
		case -3:
		case 0:
			printf( "input abort!\n" );
			return ERR;
	}

	printf( "%s = ", str );

	if( calcvalue( str, &a ) )
	{
		printf( "error!\n" );
		return ERR;
	}
	printf( "%g\n", a );
	}

	EGB_writePage( egbwork, 0 );
	screenterm( egbwork );

	return NOERR;
}
