+ Reply to Thread
Results 1 to 3 of 3

Thread: TI-BASIC Tutorial - Loops

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

    TI-BASIC Tutorial - Loops

    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

    Loops
    Loops are groups of code that run until a condition is met.
    Ti-BASIC loops can be created 3 different ways:
    First, there are While and Repeat loops
    Secondly, there are For( loops
    and Lastly, Lbl loops.

    While:
    If the condition is met, it runs the code between the While and the End until the condition is false.
    For example:
    Code:
    :0→X
    :While X<5
    :X+1→X
    :Output(1,X,"V"
    :End
    
    Outputs:
    VVVVV
    Repeat:
    If the condition is NOT met, it runs the code between the While and the End until the condition is TRUE.
    For example:
    Code:
    :0→X
    :Repeat X<5
    :X+1→X
    :Output(1,X,"V"
    :End
    
    Outputs:
    You can think of Repeat as Repeat Until <condition>

    For(:
    For( is one of the more useful loop variations.
    Syntax For(<var>, START, END, INC
    So to generate the same output as the While loop above,
    Code:
    :For(X,1,5,1
    :Output(1,X,"V"
    :End
    
    Outputs:
    VVVVV
    As you can see, using For( can really save some space and makes code look nicer.
    NOTE: If you leave off the last argument, the INC defaults to 1. The code will also run faster with the last argument omitted

    Lbl:
    Most beginners at TI-BASIC tend to use Lbl loops because they make more sense to them. Experienced user do not. One reason is that when going to a label from inside a <insert command here> ... End statement, a memory leak occurs, which reduces the available memory by around 7 bytes (which is a lot in TI-BASIC!) Another reason Lbls are avoided is because they are slow.

    To create a label loop:
    Code:
    :0→X
    :Lbl ST
    :X+1→X
    :Output(1,X,"V"
    :If X=5
    :Goto ED
    :Goto ST
    :Lbl ED
    
    Outputs:
    VVVVV
    Challenge Question Answer:
    Code:
    prgmGUESSING
    :25→X
    :While X≠A
    :Input A, "Guess Number: "
    :If A=X
    :Then
    :Disp "That's Right!"
    :Else
    :If A>X
    :Disp "Too High!"
    :If A<X
    :Disp "Too Low!"
    :End
    :End

  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 - Loops

    Good job. +rep
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Jordan Guest

    Re: TI-BASIC Tutorial - Loops

    Nice tutorial! +rep

+ 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. TI-BASIC Tutorial - Graphics
    By exfyre in forum Tutorials
    Replies: 4
    Last Post: 08-31-2009, 05:59 PM
  2. TI BASIC Tutorial - Conditions
    By exfyre in forum Tutorials
    Replies: 4
    Last Post: 08-28-2009, 07:11 PM
  3. need basic java tutorial
    By kiddies in forum Java Help
    Replies: 10
    Last Post: 08-04-2009, 04:09 AM
  4. JavaScript:Tutorial, Loops
    By TcM in forum JavaScript Tutorials
    Replies: 4
    Last Post: 12-13-2006, 06:53 AM
  5. JavaScript:Tutorial, Break Out Of Loops
    By TcM in forum JavaScript Tutorials
    Replies: 0
    Last Post: 12-08-2006, 03:35 AM

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