| I need the gotoxy() function to port PC programs to the calculator...

Previous | Miscellaneous | Next

Q: | In addition to functions from stdio.h header file, I need gotoxy function to allow porting some PC programs to TI...
A: | All printing functions from stdio.h are sensitive to MoveTo command, so it is not hard to set print position to anywhere. If you need just gotoxy, it is impossible for 4x6 font, because it is proportional. But, for 6x8 and 8x10 fonts, it may be implemented trivially:
    #define gotoxy(x,y) MoveTo (6*x-6,8*y-8)    // for 6x8 font
    #define gotoxy(x,y) MoveTo (8*x-8,10*y-10)  // for 8x10 font
Here I assumed that top-left corner is (1,1) as on PC. Note that you MUST NOT put a space between gotoxy and left bracket (else the preprocessor will define an argument-less macro). You can also define an universal gotoxy macro which will work regardless of current font setting, using smart GNU C macros:
    #define gotoxy(x,y) \
      ({short __f=2*FontGetSys(); MoveTo((4+__f)*(x-1),(6+__f)*(y-1));})
You will not be able to understand this if you are not familiar with GNU extensions.