1 / 17

TI-Nspire Programming

TI-Nspire Programming. An Introduction. Josh Schneider jschneider@ti.com. Who this session is for…. “ I’ve never programmed on anything, ever; but I have this class set of TI- Nspires … ” These guys might benefit too, but some material will be stuff you already know…

kalil
Download Presentation

TI-Nspire Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TI-Nspire Programming An Introduction Josh Schneider jschneider@ti.com

  2. Who this session is for… • “I’ve never programmed on anything, ever; but I have this class set of TI-Nspires…” • These guys might benefit too, but some material will be stuff you already know… • “I’ve never programmed on a calculator before, but I’ve done some little scripts here and there on my computer.” • “I’ve never programmed on the Nspire before, but I have worked on other TI products.” • Who will be really bored… • “I’ve not only done a ton of TI-Basic programs, I’ve also written a few Apps!”

  3. Why Programming? Programming is a passion of mine. Logic is fun! The amount of work to do always increases, while the amount of people to do it almost never does. I feel that truly effective people find ways to automate repetitive tasks in their every day life. For some students, Programming is a tangible way to teach abstract concepts of logic, causality, critical thinking, and even empathy!

  4. “Progra– what?” • An Algorithm is a list of instructions to accomplish a goal. • Think of an Algorithm as a Recipe • Ingredients become Variable Declarations • Steps become Code • Yield becomes Return • The digital expression of your Algorithm is a Program.

  5. Scripts vs Programs – An Aside • A Programming Language must be translated from the language to machine language (a process called Compiling, using a Compiler) before it can be executed. • Changes take time, you have to recompile each time you want to run. • A Scripting Language is translated from the language to machine language at runtime (Interpreting) using a piece of software called an Interpreter. • Changes can be made and tested “on the fly”. • Easier to debug. • TI BASIC is technically a scripting language.

  6. PrgmvsFunc • In the world of the TI-Nspire… • A Program (Prgm) is an expression of an algorithm. • Variables can be local or global. • Does not return a response… just output. • A Function (Func) is an expression of an algorithm that returns a response. • Variables must be local. • The Function must return a response. • Most of the commands you use in the TI-Nspire are Functions.

  7. Some Terminology Debugging is the process of stepping through code, finding, and fixing issues. A Block is “container for code”. An example, the Prgm and EndPrgm statements form a Prgm Block. Everything between those statements are treated as a program. A Conditional statement offers boolean criteria (true or false) and effects based on the response, essentially a choice for the program. A Loop allow you to repeat steps. A loop allow you to repeat steps. A loop allow you to repeat steps…

  8. Error Terminology • A Syntax Error generally means that you used a function or command incorrectly. For instance: • Solve(2x=0) would produce a syntax error, since the Solve() command requires an expression, a comma, and then a variable. • A Domain Error generally indicates that a calculation is out of the range of the calculator’s capabilities.

  9. Logic Errors • The beauty of code: It does exactly what you tell it to do. • The frustration of code: It does exactly what you tell it to do. • Logic Errors are errors in which the commands and functions are used in their proper syntax, but the code doesn’t produce the expected outcome. • This is usually because of human errors in planning. • These types of issues are common. At some point, every good programmer ends up crawling lines of code looking for an errant line. It’s a rewarding find.

  10. The Program Editor On the software: Insert a calculator page. Click on 9:Functions & Programs Choose 1:Program Editor Choose 1:New… On the device: Insert a calculator page. Press Menu Choose 9:Functions & Programs Choose 1:Program Editor Choose 1:New… • Once you’re here, start filling in the name of your program, choosing whether it’s a program or a function, and setting its library access. So here’s how to get started programming:

  11. Library Access? LibPriv means that the function or program will be available from any document, but will not display in the catalog. LibPub means that the function or program will be available from any document, and will display in the catalog. None or leaving out LibPriv/LibPub means that the function or program will only be accessible from the current document. (This is the default) You can write your functions or programs in one document using LibPriv or LibPub, and then access those programs or functions from any document!

  12. Program #1 – Hello World The “Hello World” program is the most common example of a new programming language. It is the simplest program that can be written, as it requires no input, and simply outputs the text “Hello World”. A “Hello World” program is a good way to learn the most basic structure of a programming language. Define hello()= Prgm Disp “Hello World!” EndPrgm

  13. Program #2 – Random List Generator With this program, we’ll spice things up by adding a loop and input. Since we want to return a value (making the result useful outside the program itself), we’ll do this one as a function. For the loop, I chose a For..EndFor loop since we know how many times we want to run through. The idea is, we run the function specifying how many elements we want, and the function outputs a list of that many random integers between 0-9. Define randgen(a)= Func Local b,i For i,1,a,1 b[i]:=RandInt(0,9) EndFor Return b EndFunc

  14. Program #3 – Evens or Odds? With this program, we go one step further: we’re adding conditional statements to the loop we already know. This one is being done as a program, but this time we’ll specify an input parameter. For a conditional, we use If..Then..Else…Endif. The device will evalute the stuff between If and Then, and if it is true, will execute the statements after Then. If the statement is not true, we go to Else, or exit the conditional nothing else is specified. Define evenodd(a)= Prgm For i,1,dim(a),1 If mod(a[i],2)=0 Then Disp a[i],” is even.” Else Disp a[i],” is odd.” EndIf EndFor EndPrgm

  15. Next Steps Functions are infinitely useful! You can use your functions to manipulate data in Lists and Spreadsheets, on graphs (using the Calculate tool), and in Calculator. Programs are growing more useful thanks to the TI-Nspire 2.0 addition of the Request and RequestStr commands for taking input. Always remember to Check Syntax and Save before testing your creations!

  16. Anticipating the User Users will do interesting things you did not intend. Try to keep your users in mind when writing a new program. Add conditional statements to check incoming data, and return useful error messages to the user or limit your program’s response to the data.

  17. Questions? ?

More Related