/* Sample of "value.o", linked with value.o strin.o vircon.o symbol.o
                                                    By SAKU        */
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <egb.h>
#include "strin.h"
#include "value.h"
#include "vircon.h"

#define	NOERR	0
#define	ERR		1

char	egbwork[1536];

int		main()
{
	char	str[256];
	double	a;
	char	buf[256];

	EGB_init( egbwork, 1536 );
	EGB_resolution( egbwork, 1, 3 );
	EGB_writePage( egbwork, 1 );
	EGB_displayPage( egbwork, 0, 3 );
	VC_init( egbwork, 0, 240, 60, 8, 15, 1 );

	ST_locate( 0, 0 );
	while(1)
	{
		switch( ST_inputStrings( egbwork, str, 256, "計算式を入力して下さい" ) )
		{
			case -3:
			case 0:
				VC_printf( "input abort!\n" );
				return ERR;
		}

		VC_printf( "%s = ", POINTER, str );

		if( calcvalue( str, &a ) )
		{
			VC_printf( "error!\n" );
			return ERR;
		}
		sprintf( buf, "%g\n", a );
		VC_printf( "%s", POINTER, buf );
	}

	EGB_writePage( egbwork, 0 );
	screenterm( egbwork );

	return NOERR;
}
