Texas Instruments TI-92 Calculator User Manual


 
98 Chapter 5: Additional Home Screen Topics
05ADDLHM DOC TI
-
89/TI
-
92 Plus: Additional Home Screen To
p
ics (English) SusanGullord Revised:02/23/01 10:55 AM Printed: 02/23/012:13 PM Page 98 of
You can also create a user-defined function whose definition consists
of multiple statements. The definition can include many of the
control and decision-making structures (
If
,
ElseIf
,
Return
, etc.) used
in programming.
For example, suppose you want to create a function that sums a
series of reciprocals based on an entered integer (
n
):
1
n
+
1
n
ì
1
+ ... +
1
1
When creating the definition of a multi-statement function, it may be
helpful to visualize it first in a block form.
Func
Local temp,i
If fPart(nn)ƒ0 or nn0
Return “bad argument”
0
!
temp
For i,nn,1,
ë
1
approx(temp+1/i)
!
temp
EndFor
Return temp
EndFunc
When entering a multi-statement function on the Home screen, you
must enter the entire function on a single line. Use the
Define
command just as you would for a single-statement function.
Define sumrecip(nn)=Func:Local temp,i: ... :EndFunc
On the Home screen:
You can use a user-defined function just as you would any other
function. Evaluate it by itself or include it in another expression.
Creating a Multi-
Statement Function
Note: For information about
similarities and differences
between functions and
programs, refer to
Chapter 17.
Tip: It’s easier to create a
complicated multi-statement
function in the Program
Editor than on the Home
screen. Refer to Chapter 17.
Evaluating a
Function
Enter a multi-statement
function on one line. Be
sure to include colons.
Multi-statement functions
show as “Func”.
Func
and
EndFunc
must begin and end the
function.
For information about
the individual
statements, refer to
Appendix A.
Use a colon to separate each statement.
Returns a message
if nn is not an
integer or if nn
0.
Sums the reciprocals.
Returns the sum.
Variables not in the
argument list must be
declared as local.
Use argument names that will never be used
when calling the function or program.