+ Reply to Thread
Results 1 to 4 of 4

Thread: TI-BASIC Tutorial - Input Methods

  1. #1
    exfyre is offline Newbie
    Join Date
    Feb 2008
    Posts
    16
    Rep Power
    16

    TI-BASIC Tutorial - Input Methods

    Introduction
    TI-BASIC is the built-in program language that comes with the TI-83/84+ calculators
    Optional Resources
    1. TI-83 Plus Flash Debugger -> for running programs
    2. TI Graph link -> For writing & saving programs
    -or-
    a TI-83/84 Plus calculator -> writes and runs programs


    Input Methods
    The TI BASIC programming languages have several methods of getting input from a user. The most common ways include the following:
    Code:
    :Menu(
    :Input
    :Prompt
    :GetKey
    Note: GetKey is not in this tutorial (will be in a future tutorial)
    :Menu(
    Syntax
    Code:
    Menu("Title", "Option 1", Lbl1[, "Option 2", Lbl2...]
    The syntax above has a function in TI-BASIC that I have not yet mentioned.
    Lbl1 is a label. Labels are basically checkpoints in the code with a name. When the code is told to go to the label, the processor starts from the top of the file checking each line for the correct label, and when it finds it, it starts from there.
    To set a label use the function Lbl XX
    For example:
    Code:
    :Lbl BB
    :Goto 5
    :Blahllalhlalhlahllhl skipped code blallalhlahll
    :sdgldlgslkdgsldk -> anything in here triggers no syntax error or any type of error at all because it is skipped by the Goto command
    :Lbl 5
    :Goto BB
    Labels can be anything as long as they are only 2 characters. (Use Goto to refer immediately go to a label) The previous code creates an infinite loop, and can also be written as:
    Code:
    :Lbl BB
    :Goto BB
    Now back to the Menu( command. If for example, you would like to create a menu that would let the user choose a certain type of food and then do something with that based on what they choose, Menu( is very easily implemented:
    Code:
    :Lbl MM
    :Menu("Choose Food", "Bagel", BG, "Banana", BN, "Grilled Chicken", GC, "Exit", XX
    :Lbl BG
    :Disp "You ate a bagel"
    :Pause
    :Goto MM
    :Lbl BN
    :Output(1,1, "You eat banana!"
    :Pause
    :Goto MM
    :Lbl GC
    :Text(0,0, "Eat Mor Chikin"
    :Pause
    :Goto MM
    :Lbl XX
    :ClrDraw
    :ClrHome
    :Stop
    When run, this code will give a menu with 4 options, each displaying something different when you select it, pausing, and then returning to the menu.
    Input
    Input receives expr input from a user (expr means it can be a variable or matrix or whatever as long as it matches the input type)
    Syntax for Input is as follows:
    Code:
    :Input [Var, ["Prompt"]]
    Var is the variable to which the input is stored, and "Prompt" is the message displayed to the user before they give input. If neither Var nor "Prompt" is included in the code, a crosshair will be created on the graphscreen and the calculator will get input from the coordinates.
    Examples:
    Code:
    :Input A,"Enter your age: "
    :Text(57,0,"You are ", A, " years old."
    This code will give the prompt "Enter your age: " and then will display it on the graphscreen.
    Note that Input uses the homescreen.
    Prompt
    Prompt is similar to Input. The only difference is that you dont need to give a prompt.
    For example:
    Code:
    :Prompt X, Y
    :Disp "Hypotenuse length is ", (x^2+y^2)^(1/2)
    This will display on the homescreen the following:
    Code:
    X=?
    <enters a number, say for example 4>
    Code:
    X=?4
    Y=?
    <enters another number, 3>
    Code:
    X=?4
    Y=?3
    Hypotenuse length is
                              5
    Now you know how to get input from a user.

    CHALLENGE:
    Make a program where the user tries to guess a secret number you have chosen. Hint: use Input
    Post your code here.
    Last edited by exfyre; 08-28-2009 at 06:52 PM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

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

    Re: TI-BASIC Tutorial - Input Methods

    Well done. +rep
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Jordan Guest

    Re: TI-BASIC Tutorial - Input Methods

    Very cool! +rep
    It would be fun to make a basic text-based RPG game on the TI. I like how you include a challenge at the end.

  5. #4
    exfyre is offline Newbie
    Join Date
    Feb 2008
    Posts
    16
    Rep Power
    16

    Re: TI-BASIC Tutorial - Input Methods

    Thanks. I've actually made a Text based rpg that is somewhat entertaining - and a bit buggy. I'll post it when I get a chance to download it from my calculator. It's a bit old and uses some inefficient programming techniques, but it's pretty nice.

+ 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: 2
    Last Post: 10-31-2011, 08:31 PM
  2. Basic input question
    By bgjyd834 in forum C and C++
    Replies: 6
    Last Post: 04-28-2011, 12:49 AM
  3. Best known methods for DB input forms
    By gregwarner in forum Java Help
    Replies: 2
    Last Post: 03-17-2011, 07:09 AM
  4. Beginner Tutorial: Creating a simple class with methods
    By mr mike in forum Ruby on RailsTutorials
    Replies: 0
    Last Post: 01-03-2011, 08:52 PM
  5. Basic Input and Output C++
    By 539 in forum C and C++
    Replies: 6
    Last Post: 05-06-2010, 02:01 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