DEF FN command on the TS2068

See all articles from Sinc-Link v8 n1
Author(s): John Kemeny
Publication: Sinc-Link
Pub Details: Sinc-Link v8 n1 (Volume 8, Issue 1)
Date: January/February 1990
Pages: 22

The TS2068 has a feature that allows users to define one-line functions. If you have a math formula that is used many times in the program you can program it into a ‘function’ and ‘plug’ any values you choose into it. For example, if you were going to multiply two numbers together and then divide the result by a third the formula might look like this:

(A * B)/C)

You turn this into a function by using the DEF FN (beneath the “i” key);it comes out looking like this:

DEF FN Z (A,B,C) = (A*B)/C

You&’ve now created a function called Z. When you go to use this function you ‘pass’ the values for A, B, and C by putting them in parenthesis following the function name. For example, X= FN Z (1, 2, 3). The computer plugs 1 , 2, and 3 into your little equation and gives you back the answer, in this case putting it in the variable X. The values you pass to the function don’t have to be actual numbers but can be other variables:

X = FN Z (M,N,O)

where M, N, and O have been established earlier in the program.

The following example shows a more practical use of DEF FN. It goes like this:

DEF FN S (A,B,C,) = (A>B)*(A-B)+B-(B-C)*(B>C)

This function is quite useful as a kind of bypass filter; that is:

FN S (left,x,right) =
left, if X < left;
X, if left <= X <= right
right, if X > right

The function could be used for example in a game program to keep an object within bounds. It’s also interesting to note that:

FN S (X,Y,Y) = Maximum of ((X,Y)
and
FN S (X,X,Y) = Minimum of (X,Y)

From TIME LINEZ … Retyped by G.F.C.