Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
TI-BASIC
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Examples == === Hello world === The following programs, when executed, will display the phrase "<code>[[Hello world program|HELLO, WORLD!]]</code>". ==== TI-83/84 (Z80 Series) ==== <pre> :Disp "HELLO, WORLD!" </pre> ==== TI-89 (68k Series) ==== (P.S. this code can be shortened down to just the Disp function, like in the TI-83/84, and the hellowld, prgm, and endprgm are auto-generated.)<pre> :hellowld() :Prgm :ClrIO :Disp "HELLO, WORLD!" :Pause :ClrIO :DispHome :EndPrgm </pre> ==== TI-Nspire ==== <pre> text "HELLO, WORLD!" </pre> ==== TI-Nspire CX ==== <pre> text "HELLO, WORLD!" </pre> === Lists and loops === ==== TI-83/84 (Z80 Series) ==== <pre> PROGRAM:LISTS :"ASK FOR THE NUMBER OF VARIABLES :Input "NUMBER OF VARS? ",A :"VALIDATE INPUT OR STOP :If A<1 or fPart(A) :Stop :"A FOR LOOP TO ASK FOR EACH VALUE TO BE IN THE LIST :For(N,1,A) :Input "VAR ",B :"STORE THE VALUE INTO THE NTH ELEMENT :B→L1(N) :End :"IMPLICITLY RETURN THE FINAL LIST :L1 </pre> ==== TI-89 (68k Series) ==== <pre> lists() :Prgm : Local n,i,c © Declare local variables n, i, and c. : {}→list © Initialize list as an empty list. : Input "Number of variables?",n : For i,1,n : Input "Variable #"&string(i),c © & concatenates i after it is converted to a string. : c→list[i] : EndFor :EndPrgm </pre> Lists have many possible names, this allows for many programs to manipulate many lists without overriding previous data. Lists on the TI-82 cannot have custom names (L<sub>1</sub> through L<sub>6</sub> are preprogrammed). The TI-85 and TI-86 do not have the ability to handle a variable name with subscripts. The TI-81 is completely unable to handle lists. Lists can be used by the numerous built-in TI-BASIC functions for calculating statistics, including various [[Regression analysis|regression analyses]] and [https://education.ti.com/en/guidebook/details/en/123AB1F6CF524A188FCDDF107041A019/83 more].<ref name=":0" /> These can be called inside of programs, however they still show the info while pausing execution and they cannot store specific results into variables. === Recursion === Recursion is possible. A program can be called from within itself or from within another program. ==== TI-83/84 (Z80 Series) ==== The example below is used to compute [[factorial]]s. In order for it to work, <code>X</code> is the parameter of the factorial function and <code>A</code> must equal 1. <pre> PROGRAM:FACT :If X=0 :Then :Disp A :Stop :End :XA→A :X-1→X :prgmFACT </pre> ==== TI-89 (68k Series) ==== <pre> factui() :Prgm : Local n : Define fact(x)=Func : If x=0 : Return 1 : Return x*fact(x-1) : EndFunc : Input "Input a number", n : Disp "n! = " : Disp fact(n) :EndPrgm </pre> === Functions === The 68k series makes a distinction between programs and functions. Functions are just like programs except that they do not allow statements that perform I/O, including modifying non-local variables, and they return a value, which in the absence of an explicit <code>Return</code> statement is the last expression evaluated. <pre> fact(x) :Func : If x=0 : Return 1 : If x<0 : Return undef : x*fact(x-1) :End Func </pre>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)