Anyone programming his TI calc in c here`s a fine input routine to enter numbers.Only problem is,that at the end, function atof will not convert the string properly when compiled with TIGCC IDE.
The reason is header #define MIN_AMS 100.
It works fine without it!
took me a week to figure that out!
Code:#define USE_TI89 // Compile for TI-89 #define USE_TI92PLUS // Compile for TI-92 Plus #define USE_V200 // Compile for V200 #define MIN_AMS 100 // Compile for AMS 1.00 or higher #define SAVE_SCREEN // Save/Restore LCD Contents #include <tigcclib.h> // Include All Header Files /**************Glob_Var*************************/ float Input; // converted enters tring -any input / ****************SubRoutines*********************** *********/ void InputStr(char *buffer, unsigned short maxlen); / ****************VoidInputstring******************* *********/ void InputStr(char *buffer, unsigned short maxlen) { SCR_STATE ss1; signed short key; unsigned short i = 0; buffer[0] = 0; SaveScrState (&ss1); do{ MoveTo (ss1.CurX, ss1.CurY); SaveScrState (&ss1); if ( i==3 ) {printf ("%s ", buffer);} else printf ("%s_ ", buffer); key = ngetchx (); if (key >= '0' && key <= '9' && i < maxlen) buffer[i++] = key; else if (key == KEY_BACKSPACE ) i--; else if (key==173 && i==0) buffer[i++] = key;//(-) else if (key==46)buffer[i++] = key; //comma buffer[i] = 0; } while (key != KEY_ENTER); Input = atof(buffer); } void _main(void) { int key; char str[7]; do { clrscr (); InputStr (str,7); printf("\nconverted float=%3.3f",Input); key=ngetchx(); }while (key!=KEY_ESC); }
code tags added by Hammer



LinkBack URL
About LinkBacks


