I am a young self taught programmer, however do not doubt my current abilities. BASIC should be the first language you should learn if you are an ambitious programmer. I know BASIC, assembly, learning ADO.NET and C++. But this article is focused on BASIC. You will need the following:
- TI calc preferabally a 84 since I have an 84
- A desire to stick with me through out this page
- If you find any errors or any up to date codes please change it but please no silly stuff
All right since you have made it all the way to here, I am assuming that you have a Calculator, and know how to open/and make new prgm files. So the first function is the ability to display text.
All these ways are good depending on what kind of looks and the length you are looking for. The Disp function allows a max of 16 characters. The Output function allows any number but will push any extra characters to the next line and will move down a line if the text is over 8 line. The Text function is on the Graph Screen. So you can adjust the X or Y max, min settings to your liking.
Also note that Output and Text use Y, then X instead of the usual (X,Y) coordinates.
So now try it out with these following examples:
or a variation
Program:Test2 :ClrHome :Disp "HELLO WORLD" :Pause :ClrHome
Program:Test3 :ClrHome :Output(3,4,"HELLO WORLD :Pause :ClrHome
That's it for displaying text pausing it and clearing the screen you are using.
Menus are what you use to select choices in most text games. The code for a menu with three choices.
Program:MENU :Lbl A :Menu("TEST MENU","EAT APPLES",1,"EAT PEACHES",2,"LEAVE",3) :Lbl 1 :ClrHome :Disp "YOU ATE APPLES." :Pause :Goto A :Lbl 2 :ClrHome :Disp "YOU ATE PEACHES" :Pause :Goto A :Lbl 3 :ClrHome :Disp "YOU LEFT." :Pause :Stop
Explanation for the code Edit
The code is actually simple. No, I am serious this is a totally basic BASIC code. (Heh, bad pun!)The "Lbl" labels a Menu with a letter number, or 2 digit number, or 2 letters. So once you desginate a label to a choice or menu you cannot repeat it or it will screw up. The Goto function goes back to any Labels previously made. so if I had Lbl 12 then I put somewhere later in the code: Goto 12, it means after the specified commands it will go back to the Lbl 12 and do the commands of Lbl 12. The STOP function completely ends the program, like program terminated. Do not get STOP confused with END. END just signifies this the end of the string of commands previous. That's it for Menus. NEXT: Linking Menus
Linking Menus Edit
The code for Program:MENU
:Lbl A :Menu("TEST MENU","EAT APPLES",1,"EAT PEACHES",2,"LEAVE",3) :Lbl 1 :ClrHome :Disp "YOU ATE APPLES." :Pause :Goto A :Lbl 2 :ClrHome :Disp "YOU ATE PEACHES" :Pause :Goto A :Lbl 3 :ClrHome :Disp "YOU LEFT." :Pause :Stop
This code can be made even more complex than it is by adding another menu not hard. BUT there is one snag I have to introduce to you. in order to link menus together you need to specify the Goto command to the NEXT LABEL OF THE MENU. Like this:
:Lbl A :Menu("TEST MENU","EAT APPLES",1,"EAT PEACHES",2,"LEAVE",3,"Goto MENU2",4) :Lbl 1 :ClrHome :Disp "YOU ATE APPLES." :Pause :Goto A :Lbl 2 :ClrHome :Disp "YOU ATE PEACHES" :Pause :Goto A :Lbl 3 :ClrHome :Disp "YOU LEFT." :Pause :STOP :Lbl 4 :Goto B :Lbl B :Menu("TEST MENU2","SAY BYE",5,"EAT PIZZA",6,"LEAVE",7) :Lbl 5 :ClrHome :Disp "YOU SAID BYE." :Pause :Goto B :Lbl 6 :ClrHome :Disp "YOU ATE PIZZA" :Pause :Goto B :Lbl 7 :ClrHome :Disp "YOU LEFT." :Pause :Stop
EXPLANATION FOR THE CODE Edit
The second menu has to be labeled and the choice in the TEST MENU has to specify it to Goto TEST MENU2. As for the second LEAVE see if you can improve on it. As in notice the first and second LEAVE choice. That's it for the code and Linking Menus. Your getting pretty proefficient at this aren't you if you've made it this far? Interested for the next topic and the Answer of improving the code. sorry folks but I only have the rime and strength to type in the answer. ANSWER: use the Label 3 instead of 7. WHY?: well because if you already have the label why not use it and waste around um... 30 some bytes of memory. Sorry guys this is the last time I can get on the computer so no more edits!!! Please read and keep it up to date!! thanks and good luck to you guys in CALC programming