Beispiel #1
0
Datei: main.c Projekt: wakaw/bws
float Float_Stdin(float a, float b)									//stdinからのfloat型読み込み 040928
{
	float DataInput;
	Savexy();
	while(1){
		rewind(stdin);
		fgets(buffer,BUFFER,stdin);
		sscanf(buffer,"%f",&DataInput);
		if((a<=DataInput) && (DataInput<=b))	break;
		Returnxy();
		Clear_Line();
	}
	Returnxy();
	Clear_Line();
	printf("%.3f\n",DataInput);
	return DataInput;
}
Beispiel #2
0
Datei: main.c Projekt: wakaw/bws
int Int_Stdin(int a, int b)										//stdinからのint型読み込み 040928
{
	int DataInput;
	Savexy();
	while(1){
		rewind(stdin);
		fgets(buffer,BUFFER,stdin);
		sscanf(buffer,"%d",&DataInput);
		if((a<=DataInput) && (DataInput<=b))	break;
		Returnxy();
		Clear_Line();
	}
	Returnxy();
	Clear_Line();
	printf("%d\n",DataInput);
	return DataInput;
}
Beispiel #3
0
Datei: main.c Projekt: wakaw/bws
///// 自作文字入力関数 /////////////////////////////////////////////////////////
char Yes_or_No(void)
{
	char DataInput;
	Savexy();
	while(1){
		rewind(stdin);
		fgets(buffer,BUFFER,stdin);
		sscanf(buffer,"%c",&DataInput);
		if((DataInput=='y') || (DataInput=='n'))	break;
		Returnxy();
		Clear_Line();
	}
	Returnxy();
	Clear_Line();
	printf("%c\n",DataInput);
	return DataInput;
}
int c_f(void)
{
	int r = ERR_NO;

	while(!stack_empty())
	{
		if((r = stack_pop(NULL))) break;
	}
    
    Clear_Line();

	return r;
}
Beispiel #5
0
Datei: main.c Projekt: wakaw/bws
char Char_Stdin(void)
{
	char DataInput;
	Savexy();
	rewind(stdin);
	fgets(buffer,BUFFER,stdin);
	sscanf(buffer,"%c",&DataInput);
	Returnxy();
	Clear_Line();
	printf("%c\n",DataInput);
	
	return DataInput;
}
int f_f(void)
{
	int r = ERR_NO;
	MXT_STYPE v = 0;

	while(!stack_empty())
	{
		if((r = stack_pop(&v))) break;
		printf("\n" MXT_STYPEP "\n", v);
	}
    
    Clear_Line();

	return r;
}
int p_f(void)
{
	int r = ERR_NO;
	MXT_STYPE v = 0;

	if(!(r = stack_pop(&v)))
	{
		printf("\n" MXT_STYPEP "\n", v);
        Clear_Line();
        Display_value((int) v);
        TFT_puts("\n\r");
	}

	return r;
}
Beispiel #8
0
Datei: main.c Projekt: wakaw/bws
double Double_Stdin(double a, double b)								//stdinからのDouble型読み込み 040929
{
	double DataInput;
	Savexy();
	while(1){
		rewind(stdin);
		fgets(buffer,BUFFER,stdin);
		sscanf(buffer,"%lf",&DataInput);
		if((a<=DataInput) && (DataInput<=b))	break;
		Returnxy();
		Clear_Line();
	}
	Returnxy();
	printf("%.3f\n",DataInput);
	return DataInput;
}
void error(int ec)
{
	printf("\nERR (%d)!\n", ec);
    
    Clear_Line();
    
    char buf[0x20];
    sprintf(buf, "ERR(%d)\n\r", ec);
    buf[0x1f] = '\0';
    TFT_puts(buf);
    
	switch(ec)
	{
		case ERR_STACK_FULL:
			printf("The stack is full!\n");
			break;
		case ERR_STACK_EMPTY:
			printf("The stack is empty!\n");
			break;
		case ERR_IO_NONUM:
			printf("Expected a number.\n");
			break;
		case ERR_IO_MALFORMED:
			printf("Malformed number!\n");
			break;
		case ERR_MAIN_UNKNOWN:
			printf("This command is not recognized!\n");
			break;
		case ERR_UNKNOWN:
			printf("This error should never occur.\n");
			break;
        case ERR_OVERFLOW:
            printf("Overflow error occurred.\n");
            break;
        case ERR_DIVZERO:
            printf("Tried to divide by zero.\n");
            break;
		default:
			printf("Error handler malfunction. Abort.\n");
        error:
            goto error;
	}
}