+ Reply to Thread
Results 1 to 3 of 3

Thread: TI 82 calculator tutorials Part 3 - Receiving Inputs

  1. #1
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Posts
    9,547
    Blog Entries
    5
    Rep Power
    98

    TI 82 calculator tutorials Part 3 - Receiving Inputs

    In this series of tutorials I will teach you how to program in a TI 82 calculator from the very basics. I use a TI 82 calculator and therefor I also use it for my examples but many different Texas Instruments calculator has nearly the same syntax so you don't have to use it with a TI 82.
    All my knowledge I have got by testing on boring math lessons so I've tried a lot and know what to do and what you shouldn't do.

    Parts in this series:

    Anyway, let's start with Part 3 - Receiving Inputs.


    In this part of the tutorial I will tell you how to use 4 different ways to let the user choose different options while the program is running: Input, Prompt, getKey and Menu.






    Input:

    The input function is to let the user write a value for the selected variable which then is stored in the variable:

    Code:
    Input (X)
    This code will show a question mark at the screen

    Code:
    ?
    and the user will be able to write something. When the user has written a correct value, that value is stored in the variable X.


    But if we add a title too, the questionmark is replaced by that one, we do it like this:


    Code:
    Input ("SET THE VALUE " X)




    Prompt:


    The prompt function is nearly the same as the Input function. When called the user is allowed to enter a value for the selected variable which will be stored in that variable later on. It looks like this:





    Code:
    Prompt (X)

    With the Prompt function the variable name an equal sign and a question mark is showed instead of just a question mark or a custom title. So for the above code this will be printed:

    Code:
    X=?







    getKey:

    The getKey function will return the id of the last key which was pressed. If no key has been pressed since the last time the getKey function was called, the getKey function will return 0.



    The id of a key is row number and column number added together to a string. For example, button 7 lies at row 7 and at column 2, this means its id is 72. The Enter button has id 105 since it's on row 10 and column 5. Since the On/Off button is used to stop programs this can't be used.


    Here's an example on how to use it:

    NOTE!: Since I can't use the not equals sign on my keyboard I'm writing != instead. So != means not equals to.



    Code:
    Repeat (K=105)
    getKey->K
    If K!=0
    Disp K
    End

    This loop will loop until K=105, in the beginning of each looping K gets the value of getKey. If K is not 0 we'll display the value of K.

    All this means that if no key was pressed (getKey returns 0) nothing will happen but if someone just pressed a key, that key's id is showed. If the button at id 105(the enter button) is pressed the loop will end.






    Menu:

    The menu function creates a menu where the user can select one of 1 to 7 options in a list. Depending on the selection the code will continue on different labels. We haven't learned labels yet so I teach how to use them right away, we'll get back to the Menu soon.


    Labels:


    Labels are used to make the program jump to different parts of the code. The labels are created by using "Lbl" and then the name of the label. The name of the label can contains up to 2 characters, both numbers and letters are allowed. To go to a label use the Goto function. See this example below:


    Code:
    Disp "START"
    Goto 1
    Disp "THIS WON'T BE SHOWED SINCE IT'S JUMPED OVER"
    Lbl 1
    Disp "END"

    When the code comes to Goto 1 it will simply continue on Lbl 1.





    Back to the menus, the first parameter is what the title should be. Then you can add 14 more parameters grouped up in pairs, first the text and then the label to go to if this option is selected. See the code below for an example:


    Code:
    Menu("SELECT FRUIT","BANANA",B,"APPLE",A,"ORANGE",O)
    
    Lbl B
    Disp "BANANA"
    Goto E
    
    Lbl A
    Disp "APPLE"
    Goto E
    
    Lbl O
    Disp "Orange"
    
    Lbl E

    This creates a list with the title "Select fruit" with the options "Banana", "Apple" and "Orange". Depending what the user selected the program will jump to the right Label to display the name of the fruit.




    This was all for part number 3, we'll continue in part number 4.
    Last edited by Vswe; 08-28-2009 at 04:19 PM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: TI 82 calculator tutorials Part 3 - Receiving Inputs

    Very nice! +rep

  4. #3
    Join Date
    Jul 2006
    Posts
    16,492
    Blog Entries
    75
    Rep Power
    143

    Re: TI 82 calculator tutorials Part 3 - Receiving Inputs

    Also good +rep
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 10
    Last Post: 08-28-2009, 07:35 PM
  2. Replies: 2
    Last Post: 08-28-2009, 07:32 PM
  3. Replies: 2
    Last Post: 08-28-2009, 07:28 PM
  4. Replies: 6
    Last Post: 08-28-2009, 07:27 PM
  5. Part I: Writing the basics - Calculator
    By Brandon W in forum PHP Tutorials
    Replies: 47
    Last Post: 10-11-2008, 02:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts