195
Description:
■
Creating a user-defined function
DEF
FN
creates a user-defined function.
• Definition of a user-defined function should appear preceding a calling statement
of the user-defined function in a source program.
• You cannot make double definition to a same function name.
• The
DEF
FN
statement should not be defined in the block-structured statements
(
DEF
FN
...
END
DEF
,
FOR
...
NEXT
,
FUNCTION
...
END
FUNCTION
,
IF
...
THEN
...
ELSE
...
END
IF
,
SELECT
...
CASE
...
END
SELECT
,
SUB
...
END
SUB
and
WHILE
...
WEND
), in the error-handling routine, event-handling routine, or in the
subroutines.
•
DEF
FN
functions cannot be recursive.
• The type of
functionname
should match that of the function definition
expression
.
• In defining a string function, you can specify the maximum
stringlength
for a
return value. If its specification is omitted, the default value of 40 characters takes
effect.
•
dummyparameter
, which corresponds to the variable having the same name in
the function definition
expression
, is a local variable valid only in that
expression
. Therefore, if a variable having the same name as
dummypa-
rameter
is used outside
DEF
FN
statement or used as a
dummyparameter
of any other function in the same program, then it will be independently treated.
•
expression
describes some operations for the user-defined function. It
should be within one program line including definition described left to the equal
sign (=).
•
expression
can call other user-defined functions. You can nest
DEF
FN
state-
ments to a maximum of 10 levels.
• If variables other than
dummyparameter
(s) are specified in
expression
,
they will be treated as global variables whose current values are available.
•
stringlength
should be enclosed with a pair of square brackets [ ].
■
Calling a user-defined function
FNfunctionname
calls a user-defined function.
• The number of
realparameter
s should be equal to that of
dummyparame-
ter
s, and the types of the corresponding variables used in those parameters
should be identical.
• If you specify a global variable in
realparameter
when calling a user-defined
function, the user-defined function cannot update the value of the global variable.
This is because all
realparameter
s are passed not by address but by value.
(So called "Call-by-value")
Summary of Contents for BHT-BASIC 100 SERIES
Page 1: ......
Page 161: ...153 Chapter 10 Sleep Function CONTENTS 10 1 Sleep Function 154...
Page 163: ...155 Chapter 11 Resume Function CONTENTS 11 1 Resume Function 156...
Page 173: ...165 Chapter 13 Backlight Function CONTENTS 13 1 Backlight Function 166...
Page 249: ...241 Example CLOSE IF kyIn Y THEN KILL Master Dat END IF Reference Statements CLFILE...