EasyManua.ls Logo

Texas Instruments TI-99/4A - Page 125

Texas Instruments TI-99/4A
204 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
DEFine
DEF
j numeric-function-name ((parameter)1 ""'-numeric-expression
I,
)
strin~-function'name
I(parameter)1 =
stri~-expression
I
The
DEFine
statement
allows you to define your own functions to
use within a
program.
The
function-name you specify
may
be any
valid variable name.
If
you specify a
parameter
following the
function-name, the parameter
must
be enclosed in
parentheses
and
may
be
any
valid variable name.
Note
that
if the expression
you specify
evaluates
to a
stnng
result, the function-name you use
must
be
string
variable
name
(i_e
..
the last
character
must
be a
dollar sign,
$).
The
DEFine
statement
specifies the function to be used
based
upon
the parameter (if specified), variables,
constants,
and
other
built-in
functions.
Once
a function
has
been
defined, you
may
use the
function in any
string
or
numeric
expression
by
entering
the
function-name.
The
function-name
must
be
followed
by
an
argument
enclosed in
parentheses
if a parameter
was
specified in the
DEF
statement.
If
a function
has
no parameter specified,
when
a
reference to the function is
encountered
in
an
expression, the
function is
evaluated
using the
current
values of
the
variables which
appear
in
the
DEF
statement.
If
you specify a parameter for a function, when a reference to the
function
is
encountered
in
an
expression,
the
argument
is evaluated
and its value is
assigned
to
the
parameter.
The
expression in the
DEF
statement
is then
evaluated
using the newly assigned value
of
the parameter
and
the
current
values of the
other
variables in the
DEF
statement.
User's Reference Guide
Examples:
>NEOI
>100
DEF
PI=4*ATN(1)
~110
PRINT
CO~(60*rI/180)
>120
END
>RUN
.5
**
DONE
**
>NEW
>100
REM
EVALUATE
Y=X*CX-3)
>110
DEF
Y=X*CX-3)
>120
PRINT"
X
Y"
>130
fOR
X=-2
TO
5
>140 PRINT
X;Y
>150
NEXT
X
>160
END
>RUN
X Y
-2
10
-1
4
o 0
1
-2
2
-2
3 0
4 4
5 10
**
DONE
**
>NEW
>100
REM
TAKE
A
NAME
AND
PRINT IT
BACKWARDS
>110
DEF
BACK$CX)=SEGS(NAMES,
l(,1)
>120
INPUT
"NAME?
":NAMES
>130
FOR
I=LENCNAME$)
TO
1
ST
EP
-1
>140
SNAME$=BNAME$&BACK$(l)
>150
NEXT
I
>160
PRINT
NAME$:BNAME$
>170
END
>RUN
NAME?
ROBOT
ROsOT
TOBOR
**
DONE
**
B·lOS

Other manuals for Texas Instruments TI-99/4A

Related product manuals