Greetings,
I would like to hear from anyone willing to share advice about converting a TI-Basic program into C. I have decided to do a total conversion of my TI-Basic interpolation program INTRPOL8. You can find it in the Archives here. http://ceme.tech/DL2063 For those not familiar with what can be done using interpolation please read the booklet I included with INTRPOL8 where I give many examples.

INTRPOL8 has gotten to difficult to manage using Basic so I think the next step would be to convert it into C and go from there. I am hopeful that as I come across problems converting it I can get answers here. If not, please let me know.

My first few questions are these:
Versioning: The last TI-Basic version is 2.1. Because this is a conversion to C I think that it should either be called v3.0 or maybe 'C v1.0'. What do you think would be best?

Is there an easy way to do as the TI-Basic Menu( does and invert characters with white letters and black background?
Or do I have to use fontlibc? If I have to use fontlibc how do I use the same character set as is used by TI-Basic? If you know of an example that does this I would appreciate it if you pointed me to it.

How large can a C program be. I think I read somewhere that the maximum size is 64K (65536 bytes)

Lastly, would someone be kind enough to tell me how to post a screen shot as it doesn't work the way I thought.
Hey stbradley, I wrote a "menu" in c I think that I am using for my program. I have pasted the code. You may change it how much you want, as my code is terrible and probably suits programming horror forums. It uses graphx instead of the text output... I recommend you adding extra text instead of inverting the characters as I do not know how to do that without drawing using graphx, but I think Mateo could help you with that. Versioning I think you should call it C v1.0 as you are using C. I don't think you will exceed the C program limit.

My code only allows menu choice from 0 to 9, but it shouldn't be an issue as basic only allow 0-7


Code:

short int menu(char *title, char* choices[], short int size){
    //should display:
    /*
    menu("Menu", ["select 1", "select 2", "select 3"])
    Menu
     > [0]  select 1
        [1]  select 2
        [2]  select 3
    */
    gfx_SetTextScale(1, 2);
    printCentered(title, 10);
    uint8_t loc = 0; //we are selecting 0
   
    for(uint8_t i = 0; i < size; i++){
        char text[45];
        sprintf(text, "[%d] ", i);
        strcat(text, choices[i]);
        print(text, 40, 20*i + 30);
    }
    gfx_SetColor(255);
    print(">", 20, 30);
   
    do{
       
        //(kb_Data[6] & kb_Clear) is the clear key
        kb_Scan();
        //slow down the key input thing
        //too fast, enters like 3 keystrokes per key
        while (!os_GetCSC());
        // gfx_SetTextXY(180, 200);
        // gfx_PrintInt(kb_Data[6] != kb_Enter, 1);
        // <erase length
        if(kb_Data[7] & kb_Down){
            //go down, press
            //remove at current loc
            //print("  ", 20, 30 + loc*20);
            gfx_FillRectangle_NoClip(20, 30 + loc*20, 10, 20);
            //then add loc
            loc++;
            if (loc == size){
                loc = 0;
            }
            //then redraw
            print(">", 20, 30 + loc*20);
        }
        else if(kb_Data[7] & kb_Up){
            //remove at current loc
            //print("  ", 20, 30 + loc*20);
            gfx_FillRectangle_NoClip(20, 30 + loc*20, 10, 20);
            //then add loc
            loc--;
            if(loc < 0){
                loc = size - 1;
            }
            //then redraw
            print(">", 20, 30 + loc*20);
           
        }
        else if(kb_Data[3] & kb_0){
            //print("hahaha", 0, 0);
            loc = 0;
            break;
        }
        else if(kb_Data[3] & kb_1) {

            loc = 1;
            break;
        }
        else if((kb_Data[3] & kb_4) && size >= 5){
            loc = 4;
            break;
        }
        else if((kb_Data[3] & kb_7) && size >= 8){
            loc = 7;
            break;
        }
        else if((kb_Data[4] & kb_2) && size >= 3){
            loc = 2;
            break;
        }
        else if((kb_Data[4] & kb_5) && size >= 6){
            loc = 5;
            break;
        }
        else if((kb_Data[4] & kb_8) && size >= 9){
            loc = 8;
            break;
        }
        else if((kb_Data[5] & kb_3) && size >= 4){
            loc = 3;
            break;
        }
        else if((kb_Data[5] & kb_6) && size >= 7){
            loc = 6;
            break;
        }
        else if((kb_Data[5] & kb_9) && size == 10){
            loc = 9;
            break;
        }
        // gfx_SetTextXY(200, 200);
        // gfx_PrintInt(kb_Data[6] != kb_Enter, 1);
    } while(kb_Data[6] != kb_Enter);
    // gfx_PrintInt(i, 2);
    gfx_SetTextScale(1, 1);
    return loc;
   
}
Why do you want to convert the program to C? Doing the sort of operations you want to do is way more suited to TI-BASIC -- it's going to be a nightmare to do things that are trivial in TI-BASIC.
Greetings.

Yolomep wrote:
Hey stbradley, I wrote a "menu" in c I think that I am using for my program. I have pasted the code. You may change it how much you want, as my code is terrible and probably suits programming horror forums. It uses graphx instead of the text output... I recommend you adding extra text instead of inverting the characters as I do not know how to do that without drawing using graphx, but I think Mateo could help you with that. Versioning I think you should call it C v1.0 as you are using C. I don't think you will exceed the C program limit.

My code only allows menu choice from 0 to 9, but it shouldn't be an issue as basic only allow 0-7

Thanks I'll probably borrow from it heavily.

Mateo: For the most part I don't plan on doing a direct line for line conversion rather I want to have the C version have the same "look and feel" as the Basic version. I will however need to access the list variables L1 through L6 because that is one method the user enters data into INTRPOL8, but that will be about it. I would also like to make several improvements and expand it's capabilities by adding another type of interpolation method.

The reason I want to change from Basic to C is because the Basic version has gotten somewhat unwieldy. During my last update of it last year I was getting a headache trying to keep everything straight, hence the reason I created a "Hacking" doc which I include with the download just to keep everything straight. If you look at that doc you will note that I have used all the variable A-Z, Str variables. and was using the L1 list as additional memory storage while at the same time allowing the user to use L1 to store their own data. Using C I can get away from all those constraints (and headaches Very Happy ). It has also gotten quite large which has made it difficult to edit let alone add features. Lastly, I prefer to write programs in C, I've been using C decades longer then Basic.

As for the Menu( it isn't really that important if the characters are white with black background, If it is to much trouble I'll just keep it black characters with white background. I just thought it might look nice.
  
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 1 of 1
» 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