This is what I do in ImgViewer:

Code:

      #define INPUT_MAX_LEN 8
      unsigned char inputBuf[] = "\0\0\0\0\0\0\0\0\0\0";
      /* other code */
      PrintXY(1,1,"XXEnter filename:",TEXT_MODE_NORMAL, TEXT_COLOR_BLUE);
      
      getTextLine(inputBuf, INPUT_MAX_LEN, 1, 2, INPUT_MAX_LEN, INPUT_MODE_TEXT);

You can change inputBuf to have default text showing up in that area (i.e. without any input).
So where inputBuf is I could put a string?
What is the INPUT_MAX_LEN andINPUT_MODE_TEXT?
What I want to do with this is have someone enter a number so I could insert it into an equation.

As a side note: why is there XX in front of "Enter filename"?

Edit: any ideas I try to compile and I get this.

Code:

C:\PrizmSDK-0.3\PrizmSDK-0.3\projects\MathAdd-In>..\..\bin\make.exe
sh3eb-elf-gcc -MMD -MP -MF C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/buil
d/MathAdd-In.d -Os -Wall -mb -m4a-nofpu -mhitachi -nostdlib   -IC:/PrizmSDK-0.3/
PrizmSDK-0.3/projects/MathAdd-In/build -IC:/PrizmSDK-0.3/PrizmSDK-0.3/include -c
 C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c -o MathAdd-In
.o
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:5:18: fatal er
ror: math.h: No such file or directory
compilation terminated.
make[1]: *** [MathAdd-In.o] Error 1
make: *** [build] Error 2

C:\PrizmSDK-0.3\PrizmSDK-0.3\projects\MathAdd-In>pause
Press any key to continue . . .
The INPUT_MODE_TEXT is used by Kerm's input routine to determine what type of input to get:

Code:
#define INPUT_MODE_TEXT 0
#define INPUT_MODE_FLOAT 1
#define INPUT_MODE_INT 2
#define INPUT_MODE_POSINT 3

INPUT_MAX_LEN is the maximum length of the input, and the "XX" is there because PrintXY ignores the first two characters of the string passed to it. I don't think we have a math.h, so that's why you're getting an error in the second part of your post.
Would I define INPUT_MAX_LEN?
And could you replace inputBuf with (for example) "A"?

Edit: any ideas on this?

Code:

C:\PrizmSDK-0.3\PrizmSDK-0.3\projects\MathAdd-In>..\..\bin\make.exe
sh3eb-elf-gcc -MMD -MP -MF C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/buil
d/MathAdd-In.d -Os -Wall -mb -m4a-nofpu -mhitachi -nostdlib   -IC:/PrizmSDK-0.3/
PrizmSDK-0.3/projects/MathAdd-In/build -IC:/PrizmSDK-0.3/PrizmSDK-0.3/include -c
 C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c -o MathAdd-In
.o
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function '
GetKeyNB':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:19:12: error:
expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:99:36: error:
expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:109:36: error:
 expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:119:20: error:
 expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:126:96: error:
 expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:302:92: error:
 expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:325:23: error:
 expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:7:5: error: ol
d-style parameter declarations in prototyped function definition
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:329:1: error:
expected '{' at end of input
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:329:1: warning
: control reaches end of non-void function [-Wreturn-type]
make[1]: *** [MathAdd-In.o] Error 1
make: *** [build] Error 2

C:\PrizmSDK-0.3\PrizmSDK-0.3\projects\MathAdd-In>pause
Press any key to continue . . .
Quote:
Would I define INPUT_MAX_LEN?
You can do a #define the way Souvik did, or you can simply put 8 (or your value) in its place. We prefer the #define method, because it prevents a profusion of what we call "magic numbers" in your code.
Quote:
And could you replace inputBuf with text?
Yes. For example:


Code:
unsigned char inputBuf[] = "A\0\0\0\0\0\0\0\0\0";
Because of the way that getTextLine is written, you don't need to put the initial "XX" padding in the input/output buffer.
So do you need all the \0's in the string "A\0\0\0\0\0\0\0\0\0"?
krazylegodrummer56 wrote:
So do you need all the \0's in the string "A\0\0\0\0\0\0\0\0\0"?
For Souvik's specific application, yes. It would be better this way, though:


Code:
#define BUFLEN 512
...
char mybuffer[BUFLEN];
strcpy(mybuffer,"Initial string");
getTextLine(inputBuf, BUFLEN-1, 1, 2, 18, INPUT_MODE_TEXT);
KermMartian wrote:
It would be better this way, though:


Code:
#define BUFLEN 512
...
char mybuffer[BUFLEN];
strcpy(mybuffer,"Initial string");
getTextLine(inputBuf, BUFLEN-1, 1, 2, 18, INPUT_MODE_TEXT);

how would you ask for an int to use in the program?
You mean like this? Or something different?
Code:
int main(...) {
char mybuffer[BUFLEN];
int someinteger;
int anotherint = 1;
int something = 2, blah = -345;
Do you want the user to input an integer?

Code:

char* inputBuf;
getTextLine(inputBuf, INPUT_MAX_LEN, 1, 2, INPUT_MAX_LEN, INPUT_MODE_INT);   //INPUT_MODE_INT is 2
int someInteger  = atoi(inputBuf);
what I want to do is this:

Code:
A?
//user inserts int
B?
//user inserts int
//A*B->C
display C


Also I get this when I try to compile:

Code:

C:\PrizmSDK-0.3\PrizmSDK-0.3\projects\MathAdd-In>..\..\bin\make.exe
sh3eb-elf-gcc -MMD -MP -MF C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/buil
d/MathAdd-In.d -Os -Wall -mb -m4a-nofpu -mhitachi -nostdlib   -IC:/PrizmSDK-0.3/
PrizmSDK-0.3/projects/MathAdd-In/build -IC:/PrizmSDK-0.3/PrizmSDK-0.3/include -c
 C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c -o MathAdd-In
.o
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function '
main':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:26:3: warning:
 implicit declaration of function 'keyupdate' [-Wimplicit-function-declaration]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:55:13: error:
'mode_joint' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:55:13: note: e
ach undeclared identifier is reported only once for each function it appears in
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:58:13: error:
'mode_inverse' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:61:13: error:
'mode_direct' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:94:4: error: m
ultiple default labels in one switch
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:81:5: error: t
his is the first default label
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function '
keydownlast':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:111:18: error:
 'lastkey' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:106:18: warnin
g: variable 'word' set but not used [-Wunused-but-set-variable]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function '
keydownhold':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:121:18: error:
 'holdkey' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:116:18: warnin
g: variable 'word' set but not used [-Wunused-but-set-variable]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function '
keymenu':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:128:2: warning
: implicit declaration of function 'Bdisp_EnableColor' [-Wimplicit-function-decl
aration]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function '
getTextLine':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:139:2: warning
: implicit declaration of function 'RTC_GetTicks' [-Wimplicit-function-declarati
on]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:141:2: error:
unknown type name 'bool'
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:181:3: error:
unknown type name 'bool'
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:215:23: error:
 'KEY_PRGM_DEL' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:235:8: warning
: implicit declaration of function '_g_strlen' [-Wimplicit-function-declaration]

C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:244:11: error:
 'for' loop initial declarations are only allowed in C99 mode
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:244:11: note:
use option -std=c99 or -std=gnu99 to compile your code
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:276:9: error:
'for' loop initial declarations are only allowed in C99 mode
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:279:17: error:
 redefinition of 'i'
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:276:17: note:
previous definition of 'i' was here
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:279:9: error:
'for' loop initial declarations are only allowed in C99 mode
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:296:34: error:
 'CURSOR_FLASH_RATE' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function '
keydownhold':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:122:1: warning
: control reaches end of non-void function [-Wreturn-type]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function '
keydownlast':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:112:1: warning
: control reaches end of non-void function [-Wreturn-type]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function '
main':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:104:1: warning
: control reaches end of non-void function [-Wreturn-type]
make[1]: *** [MathAdd-In.o] Error 1
make: *** [build] Error 2

C:\PrizmSDK-0.3\PrizmSDK-0.3\projects\MathAdd-In>pause
Press any key to continue . . .


ask for code if need be
Well, it gives you tons of line numbers, so how about a few of the lines it mentions, plus the line immediately before and after each? Smile
I already looked and don't understand what the problem really is.

here is my code so far:

Code:
#include <keyboard_syscalls.h>
#include <keyboard.hpp>
#include <display_syscalls.h>
#include <color.h>

void keymenu(void);
int PRGM_GetKey(void);
int keydownlast(int basic_keycode);
int keydownhold(int basic_keycode);
void DrawCursor(int x, int y, int shiftmode, int alphamode, int cursorstate, char curchar);
int getTextLine(char* buf, int maxstrlen, int x, int y, int maxdisplen, unsigned short inmode);

#define true 1
#define false 0
#define INPUT_MODE_TEXT 0 
#define INPUT_MODE_FLOAT 1 
#define INPUT_MODE_INT 2 
#define INPUT_MODE_POSINT 3

int main() {
   
   enum { mode_title, mode_discrim, mode_vary, mode_quadrat } mode = mode_title;
   _Bool running = true;
   
   while(running) {
      keyupdate();
      switch(mode) {
         case mode_title:
            PrintXY(1, 1, "XXkrazylegodrummer56's", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            PrintXY(3, 2, "XXEquation solver", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            PrintXY(4, 4, "XXF1: Discriminant", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            PrintXY(4, 5, "XXF2: Variations", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            PrintXY(4, 6, "XXF3: Quadratic equation", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            if(keydownlast(KEY_PRGM_F1)) {
               mode = mode_discrim;
               continue;
            } else if(keydownlast(KEY_PRGM_F2)) {
               mode = mode_vary;
               continue;
            } else if(keydownlast(KEY_PRGM_F3)) {
               mode = mode_quadrat;
               continue;
            }
            break;
         case mode_discrim:
            PrintXY(4, 6, "XXDiscriminant", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            
            break;
         case mode_vary:
            PrintXY(4, 2, "XXVariations", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            PrintXY(4, 4, "XXF1: Varies Jointly", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            PrintXY(4, 5, "XXF2: Varies Inversely", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            PrintXY(4, 6, "XXF3: Varies Directly", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            if(keydownlast(KEY_PRGM_F1)) {
               mode = mode_joint;
               continue;
            } else if(keydownlast(KEY_PRGM_F2)) {
               mode = mode_inverse;
               continue;
            } else if(keydownlast(KEY_PRGM_F3)) {
               mode = mode_direct;
               continue;
            }
            break;
            case mode_joint:
               PrintXY(4, 6, "XXY=KX", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            
            
            break;
            case mode_inverse:
               PrintXY(4, 6, "XXY=KXZ", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            
            
            break;
            case mode_direct:
               PrintXY(4, 6, "XXY=K/X", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            
            
            break;
               break;
               break;
               if(keydownlast(KEY_PRGM_MENU)) {
               keymenu();
            } else if(keydownlast(KEY_PRGM_EXIT)) {
               mode = mode_title;
            }
            Bdisp_PutDisp_DD();
         case mode_quadrat:
            PrintXY(4, 6, "XXQuadratic Equation", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
            
            
            break;
         default:
            break;
      }
      if(keydownlast(KEY_PRGM_MENU)) {
         keymenu();
      } else if(keydownlast(KEY_PRGM_EXIT)) {
         mode = mode_title;
      }
      Bdisp_PutDisp_DD();
   }
}
int keydownlast(int basic_keycode) {
   int row, col, word, bit;
   row = basic_keycode%10;
   col = basic_keycode/10-1;
   word = row>>1;
   bit = col + 8*(row&1);
   return (0 != (lastkey[word] & 1<<bit));
}


int keydownhold(int basic_keycode) {
   int row, col, word, bit;
   row = basic_keycode%10;
   col = basic_keycode/10-1;
   word = row>>1;
   bit = col + 8*(row&1);
   return (0 != (holdkey[word] & 1<<bit));
}


void keymenu(void) {
   int key = KEY_PRGM_MENU;
   GetKey(&key);
   Bdisp_EnableColor(1);
   DrawFrame(COLOR_BLACK);
}

int getTextLine(char* buf, int maxstrlen, int x, int y, int maxdisplen, unsigned short inmode) {
   //state variables
   int dispoffset = 0;         //the offset of the starting char displayed
   int stroffset = 0;         //the offset of the cursor into the string
   int curlen = 0;            //current string length (<= maxstrlen)
   int cursorstate = 0;         // 0 = char shown, 1 = cursor shown
   int shiftmode = 0, alphamode = 0;
   int cursorchangetime = RTC_GetTicks();   //last cursor change time
   int kcol, krow;
   bool finished = false;      //if routine should end
   unsigned short key = 0;
   char dispcharbuf[21+2+1];   //max possible width is 21, 2 chars for the XX, 1 for null term
   dispcharbuf[0] = dispcharbuf[1] = 'X';
   
   char* row0[18] = { "", "^2", "^", "", "", "",   "", "sqrt(", "xrt(", "", "", "",  "", "r", "Theta", "", "", ""};
   char* row1[18] = { "X", "log(", "ln(", "sin(", "cos(", "tan(",  "angle", "10x", "ex", "sin^-1(", "cos^-1(", "tan^-1(", "A", "B", "C", "D", "E", "F"};
   char* row2[18] = { "", "", "(", ")", ", ", "", "", "", "cuberoot(", "^-1", "", "", "G", "H", "I", "J", "K", "L"};
   char* row3[18] = { "7", "8", "9", "", "", "", "", "", "", "", "", "", "M", "N", "O", "", "", ""};
   char* row4[18] = { "4", "5", "6", "*", "/", "", "", "", "", "{", "}", "", "P", "Q", "R", "S", "T", ""};
   char* row5[18] = { "1", "2", "3", "+", "-", "", "", "", "", "[", "]", "", "U", "V", "W", "X", "Y", ""};
   char* row6[18] = { "0", ".", "E", "-", "", "", "i", "=", "pi", "Ans", "", "", "Z", " ", "\"", "", "", ""};
   char** rows[7] = { row0, row1, row2, row3, row4, row5, row6 };
   //First, figure out starting position
   while(buf[curlen] != '\0') {
      curlen++;
      if (curlen > maxstrlen)
         return -1;
   }
   stroffset = curlen;
   if (curlen >= maxdisplen)
      dispoffset = curlen-maxdisplen+1;
   
   //Main loop
   do {
   
      // display initial buffer contents
      int i=0;   //copy chars into the buffer
      while(i<maxdisplen && buf[dispoffset+i] != '\0') {
         dispcharbuf[2+i] = buf[dispoffset+i];
         i++;
      }
      while(i<maxdisplen) {
         dispcharbuf[2+i++] = ' ';
      }
      dispcharbuf[2+i] = '\0';         //null terminate it
      PrintXY(x,y,dispcharbuf,0,TEXT_COLOR_BLACK);
      cursorstate = 1;
      DrawCursor(x+(stroffset-dispoffset),y,shiftmode,alphamode,cursorstate,dispcharbuf[2+stroffset-dispoffset]);

      bool redraw = false;
      do {
         key = kcol = krow = 0;
         int retval = GetKeyWait_OS(&kcol,&krow,KEYWAIT_HALTON_TIMERON,1,0,&key);
         Bdisp_EnableColor(1);
         key = (10*kcol)+(krow - 1);
         if (retval == 1) {
            
            //erase the cursor and switch it back to the letter here
            cursorstate = 0;
            cursorchangetime = RTC_GetTicks();
            DrawCursor(x+(stroffset-dispoffset),y,shiftmode,alphamode,0,dispcharbuf[2+stroffset-dispoffset]);

            if (krow == 10 || key == KEY_PRGM_UP || key == KEY_PRGM_DOWN || key == KEY_PRGM_RETURN)
               return key;
            if (key == KEY_PRGM_SHIFT) {
               shiftmode = 1-shiftmode;
            } else if (key == KEY_PRGM_ALPHA) {
               if (shiftmode == 1) alphamode = 2;
               else if (alphamode != 2) alphamode = 1-alphamode;
               else alphamode = 0;
               shiftmode = 0;
            } else if (key == KEY_PRGM_LEFT && stroffset != 0) {
               redraw = true;   //cursor               
               if (stroffset == dispoffset) {
                  dispoffset--;
               }
               stroffset--;
            } else if (key == KEY_PRGM_RIGHT && stroffset < curlen) {
               redraw = true;   //cursor               
               if (stroffset == dispoffset+maxdisplen-1) {
                  dispoffset++;
               }
               stroffset++;
            } else if (key == KEY_PRGM_DEL && stroffset < curlen) {
               int i = stroffset;
               do {
                  buf[i] = buf[i+1];
                  i++;
               } while (buf[i] != '\0');
               curlen--;
               redraw = true;
            } else if (key == KEY_PRGM_DEL && stroffset == curlen && stroffset > 0) {
               curlen--;
               stroffset--;
               buf[stroffset] = '\0';
               redraw = true;
               if (stroffset <= dispoffset && dispoffset > 0)
                  dispoffset--;
            } else {
               if (krow <= 8 && krow >= 2) {
                  char** rowdef = rows[8-krow];
                  char* thisstr = rowdef[6*(shiftmode)+12*(alphamode!=0 && shiftmode == 0)+(7-kcol)];
                  if (*thisstr != '\0') {
                     int len = _g_strlen(thisstr);
                     signed char valid = (len+curlen < maxstrlen);
                     switch (inmode) {
                        case INPUT_MODE_FLOAT:
                           if (len > 1) valid = false;
                           else if (*thisstr == '-') {
                              if (stroffset != 0 || buf[stroffset] == '-')
                                 valid = false;
                           } else if (*thisstr == '.') {
                              for(int i=0; i<curlen; i++) {
                                 if (buf[i] == '.') {
                                    valid = false;
                                    break;
                                 }
                              }
                           } else if (*thisstr >= '0' && *thisstr <= '9') {
                              //this is fine
                           } else valid = false;
                           break;
                        case INPUT_MODE_INT:
                           if (len > 1) valid = false;
                           else if (*thisstr == '-') {
                              if (stroffset != 0 || buf[stroffset] == '-')
                                 valid = false;
                           } else if (*thisstr >= '0' && *thisstr <= '9') {
                              //this is fine
                           } else valid = false;
                           break;
                        case INPUT_MODE_POSINT:
                           if (len > 1) valid = false;
                           else if (*thisstr >= '0' && *thisstr <= '9') {
                              //this is fine
                           } else valid = false;
                           break;
                        case INPUT_MODE_TEXT:
                        default:
                           valid = true;
                           break;
                     }

                     if (valid) {
                        for(int i=curlen+len;i>=stroffset+len;i--) {   //make space to insert this
                           buf[i] = buf[i-len];
                        }
                        for(int i=0; i<len; i++) {                  //drop it into the space
                           buf[stroffset++] = thisstr[i];
                        }
                        curlen+=len;
                        while (stroffset == dispoffset+maxdisplen-1) {   //adjust the cursor to be on-screen
                           redraw = true;
                           dispoffset++;
                        }
                     }
                     redraw = 1;
                     if (shiftmode)
                        shiftmode = 0;
                     else if (alphamode == 1)
                        alphamode = 0;
                  }
               }
            }
         } else if (cursorchangetime + CURSOR_FLASH_RATE < RTC_GetTicks()) {   //and !key
            cursorstate = 1-cursorstate;
            cursorchangetime = RTC_GetTicks();
            DrawCursor(x+(stroffset-dispoffset),y,shiftmode,alphamode,cursorstate,dispcharbuf[2+stroffset-dispoffset]);
         }
      } while (!redraw && !finished);
   
   } while(!finished);
   
   return KEY_PRGM_RETURN;   
}
         
void DrawCursor(int x, int y, int shiftmode, int alphamode, int cursorstate, char curchar) {
   char buf2[5] = {'X','X',' ','\0','\0'};
   buf2[2] = (curchar?curchar:' ');
   if (cursorstate) {
      if (shiftmode == 0 && alphamode == 0) {
         PrintXY(x,y,buf2,1,TEXT_COLOR_BLACK);
         Bdisp_PutDisp_DD();
         return;
      } else if (shiftmode) {
         buf2[2] = 0xE5;
         buf2[3] = 0xEA;
      } else if (alphamode == 1) {
         buf2[2] = 0xE5;
         buf2[3] = 0x9F;
      } else {
         buf2[2] = 0xE7;
         buf2[3] = 0xAE;
      }
   }
   PrintXY(x,y,buf2,0,TEXT_COLOR_BLACK);
   Bdisp_PutDisp_DD();
}

int PRGM_GetKey(void) {
  unsigned char buffer[12];
  PRGM_GetKey_OS( buffer );
  return ( buffer[1] & 0x0F ) * 10 + ( ( buffer[2] & 0xF0 ) >> 4 );
}


You have to put an underscore before "main.
"
Where blue?
blue_bear_94 wrote:
You have to put an underscore before "main.
"


Incorrect. "_main" is the assembly label for what "main" is in C. The assembly compilation adds underscores before function names when the labels are put in. What the problem is, is that main isn't being defined correctly. My first guess is that you need to declare it as "int main(void)", and if that doesn't fix it, something is wrong with the build system. Personally, changing main's signature to that fixed it for me.
When I tried to make it again:

Code:


C:\PrizmSDK-0.3\PrizmSDK-0.3\projects\MathAdd-In>..\..\bin\make.exe 
sh3eb-elf-gcc -MMD -MP -MF C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/build/MathAdd-In.d -Os -Wall -mb -m4a-nofpu -mhitachi -nostdlib   -IC:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/build -IC:/PrizmSDK-0.3/PrizmSDK-0.3/include -c C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c -o MathAdd-In.o
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function 'main':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:26:3: warning: implicit declaration of function 'keyupdate' [-Wimplicit-function-declaration]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:55:13: error: 'mode_joint' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:55:13: note: each undeclared identifier is reported only once for each function it appears in
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:58:13: error: 'mode_inverse' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:61:13: error: 'mode_direct' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:94:4: error: multiple default labels in one switch
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:81:5: error: this is the first default label
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function 'keydownlast':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:111:18: error: 'lastkey' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:106:18: warning: variable 'word' set but not used [-Wunused-but-set-variable]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function 'keydownhold':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:121:18: error: 'holdkey' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:116:18: warning: variable 'word' set but not used [-Wunused-but-set-variable]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function 'keymenu':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:128:2: warning: implicit declaration of function 'Bdisp_EnableColor' [-Wimplicit-function-declaration]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function 'getTextLine':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:139:2: warning: implicit declaration of function 'RTC_GetTicks' [-Wimplicit-function-declaration]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:141:2: error: unknown type name 'bool'
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:181:3: error: unknown type name 'bool'
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:215:23: error: 'KEY_PRGM_DEL' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:235:8: warning: implicit declaration of function '_g_strlen' [-Wimplicit-function-declaration]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:244:11: error: 'for' loop initial declarations are only allowed in C99 mode
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:244:11: note: use option -std=c99 or -std=gnu99 to compile your code
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:276:9: error: 'for' loop initial declarations are only allowed in C99 mode
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:279:17: error: redefinition of 'i'
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:276:17: note: previous definition of 'i' was here
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:279:9: error: 'for' loop initial declarations are only allowed in C99 mode
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:296:34: error: 'CURSOR_FLASH_RATE' undeclared (first use in this function)
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function 'keydownhold':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:122:1: warning: control reaches end of non-void function [-Wreturn-type]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function 'keydownlast':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:112:1: warning: control reaches end of non-void function [-Wreturn-type]
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c: In function 'main':
C:/PrizmSDK-0.3/PrizmSDK-0.3/projects/MathAdd-In/src/MathAdd-In.c:104:1: warning: control reaches end of non-void function [-Wreturn-type]
make[1]: *** [MathAdd-In.o] Error 1
make: *** [build] Error 2

C:\PrizmSDK-0.3\PrizmSDK-0.3\projects\MathAdd-In>pause
Press any key to continue . . .

Okay, you fixed that problem. Now go down the list, read the descriptions of what's going out of whack, and fix them Wink most of those are pretty simple fixes if you've read a C tutorial. You'll learn more if you fix them to the best of your ability, and for the ones you can't figure out without consulting the tutorial you're using and/or Google, feel free to ask here.
You have a bunch of stuff that's undeclared, your switch statement seems broken, you redefine i, you use bool which isn't a datatype in C, and you aren't using C99 mode (which lets you use initial declarations in for loops).
where and how do I turn on c99 mode?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 4
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement