Ti N Spire Cas Enter Entry Again
Iii new programming commands were introduced in the 2010 update, all defining floating dialog boxes: "Text" (which displays strings in a floating window), "Request" (which allows a cord as a question and accepts the numeric outcome every bit a variable, and "RequestStr" which accepts the response equally a cord. Both Asking and RequestStr have their question string limited to twoscore characters, while Text is limited only past the size of the viewable window.
The case shown uses the "Text" command to display a statement, the elements of which are randomly generated. Upon pressing enter, the text is dropped into the Calculator entry line as a display and serves as a tape of the interaction.
These dialog boxes may be used just inside programs (non functions). Now programs can be run within the Calculator and as well within Notes; however, when running in Notes, there is no brandish of intermediate steps (including dialog boxes) and then all that appears in the Notes folio is the result "Done". To see displayed steps and dialog boxes, such programs need to be run within the Calculator.
It is worthwhile studying the plan structure for this elementary fiddling example. The offset line defines the programme proper noun ("quiz0") and in this case, it takes no argument (nothing in the parentheses). The next line begins the Prgm syntax and a annotate line appearing before annihilation else will appear equally help in the Catalog (up to twoscore characters).
Next nosotros define any variables that we are going to utilise as Local, so that they do not hang around after the program has run. If we want variables to remain afterwards (global) only don't include them in the "Local" listing.
For this program, we demand a random variable for x (we will call is "xv") and we will need the final result ("answer") besides as the "question". Note the style that the question is divers using, not a "when" statement, but an "If...then...Else...EndIf" block. Again, as with previous examples, the diverse string components are glued together with "&". Finally, the "Text" command displays the dialog box.
To view a divers program (or to Import one from a Library file) use the "Insert" bill of fare under "Plan Editor".
For a slightly more interesting example, we could use the prand part from the Polynomial Toolkit to generate a random expression. This really makes the programme even simpler. Define a function "fn" as a random polynomial of degree 1, define "fifteen" as a random integer, and and so ascertain the answer as a string which uses the "expr" command to evaluate a cord. Hence, if we take a string "ii+three" and then expr("2+3") will actually output the numeric result 5.
In this example, we glue together strings to form the argument, fn|x=xv using fn&"|ten="&string(xv). Taking the expr of this volition evaluate it, and we want the output equally a cord, hence we go the form string(expr(fn&"|x="&string(xv))).
Now for something a bit more interactive: a random polynomial is generated and students are asked to substitute the value of a random variable.
This involves a "Request" command and the plan evaluates the answer that the student types and responds with either "Yes!" or "Pitiful", followed past the correct statement.
Can yous see how this might be ready?
Just equally before, but this fourth dimension we introduce a new Local variable called "input" (we tin can call these variables annihilation nosotros like, of class). We define our random function using prand (Note that nosotros have actually imported prand into this problem so we no longer need to bespeak the path back to the poly.tns file which is its source). Nosotros also define our random variable xv and our answer.
Then the simple "Request" command: Request "Text",input.
The input is tested against our answer and the feedback is provided accordingly.
Finally, we add ii finishing touches: the ability for students to enter their ain question, and the feedback being a little more forgiving: if they get it wrong, they become another take a chance; if wrong over again, information technology gives them the result.
Study the program shown and see how these effects are achieved.
Right at the start, we see the "RequestStr" command used, allowing students to enter their own part and have it received as a string. The xpress function from the Polynomial Toolkit ensures that it is presented correctly.
This brief introduction to programming on TI-Nspire™ hopefully provides a sufficient taster to get you started trying out your ain programs - and these are limited only by your imagination!
___________________________________
APPENDIX: Some Useful Commands
ApproxRational(number) - converts (where possible) a decimal to an exact form equally either integer or fraction. For example, ApproxRational(0.6) = 3/v. When evaluating the results of strings, even whole numbers may come out with a decimal betoken (such as "2."). Use this control to render to squeamish whole number form: ApproxRational(ii.) = two.
expr(string) - evaluates (where possible) a string and outputs a numeric result. For example, expr("2+three") = 5.
GetType(input) - a useful test for whether a function or programme is divers: For case,
If gettype(xpress)≠"FUNC" then
poly\xpress(fn)
Else
xpress(fn)
EndIf
The principal types are "NUM", "STR", "FUNC", "PRGM", "MAT".
cord(number) - returns the result as a string.
Effort
Include your entire programme here
Else
ClrErr
EndTry
This niggling block command is Gold! Cannot be used with functions, only programs.
What happens during a plan if a educatee does the incorrect thing? Types in a alphabetic character when the input is expecting a string? Hits ESC or types nothing and just presses enter instead? Usually, an error dialog will come up upwardly, inviting the user to get to the source of the problem and helpfully opening the program code!
This is not at all what nosotros want our students to be doing when they use our programs. Past wrapping a Endeavour...Else...EndTry cake around our program, if annihilation unexpected happens, the program simply quits - no error messages, no invitations to fiddle with our lawmaking! As well as the important ClrErr command, you lot can even include some other actions - similar a message that warns them that they did something wrong!
___________________________________
Source: https://compasstech.com.au/TNS_Authoring/interactivedocs2/index.html
0 Response to "Ti N Spire Cas Enter Entry Again"
Post a Comment