
215
Description:
■
Creating a user-defined function
FUNCTION
...
END
FUNCTION
creates a user-defined function. The function defini-
tion block between
FUNCTION
and
END
FUNCTION
is a set of some statements
and functions.
• You cannot make double definition to a same function name.
• This statement block 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.
•
FUNCTION
...
END
FUNCTION
functions can be recursive.
• In defining a string function, you can specify the maximum
stringlength
. 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 block, is a local variable valid only in that block. Therefore,
if a variable having the same name as
dummyparameter
is used outside
FUNCTION
...
END
FUNCTION
statement block or used as a
dummyparame-
ter
of any other function in the same program, then it will be independently
treated.
• In user-defined functions, you can call other user-defined functions. You can nest
FUNCTION
...
END
FUNCTION
statements to a maximum of 10 levels.
• When using the
FUNCTION
...
END
FUNCTION
together with 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
), you can nest them to a maximum of 30 levels.
• If variables other than
dummyparameter
(s) are specified in the function defini-
tion block, they will be treated as local variables whose current values are avail-
able only in that function definition block, unless
PRIVATE
or
GLOBAL
is
specified.
•
EXIT
FUNCTION
exits the function block prematurely and returns control to the
position immediately after the statement that called the user-defined function.
• Using Syntax 5 allows you to assign a return value for a user-defined function.
The type of
funcname
should match that of a return value. If no return value is
assigned to
funcname
, then the value 0 or a null string will be returned for a
numeric function or a string function, respectively.
■
Calling a user-defined function
funcname
calls the 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.
Содержание BHT-BASIC 100 SERIES
Страница 1: ......
Страница 161: ...153 Chapter 10 Sleep Function CONTENTS 10 1 Sleep Function 154...
Страница 163: ...155 Chapter 11 Resume Function CONTENTS 11 1 Resume Function 156...
Страница 173: ...165 Chapter 13 Backlight Function CONTENTS 13 1 Backlight Function 166...
Страница 192: ...Chapter 14 Statement Reference 184 Example OPEN master Dat AS 1 FIELD 1 20 AS bar 10 AS ky CLFILE 1 CLOSE 1...
Страница 249: ...241 Example CLOSE IF kyIn Y THEN KILL Master Dat END IF Reference Statements CLFILE...
Страница 349: ...341 Run time errors Error code Meaning 05h Parameter out of the range checktype is out of the range...
Страница 383: ...375 Run time errors Reference Error code Meaning 05h Parameter out of the range Functions LEFT LEN and RIGHT...