87
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
dim
a(
10
)
as
integer
dim
f
as
byte
for
f = 0
to
9
' in a 10-member array, element indices are 0 to 9
sum = sum + a(f)
next
f
Function Statement
Function:
-- distinct units in code which
perform specific tasks and always return a value.
Syntax:
[ public ]
function name [ ( [ byref ] argument1 as type1, [ byref
] argument2 as type2…) ]
as ret_type
statement1
statement2
…
[exit function]
…
statementN
end function
Scope:
Global
See Also:
,
,
Part
Description
public
Optional. If set, allows other compilation units (files in a
project) to access the function.
name
Required. Specifies the name for the function (used to call
it, etc).
byref
Optional. If present, the argument immediately following
this modifier will be passed
.
argument[1, 2...]
Optional. The name of the argument(s) passed to the
function; arguments must have a name which is a valid
identifier. This is a local identifier, used to refer to these
arguments within the body of the function.
as
Optional (required if arguments are specified). Precedes the
type definition.
type[1, 2...]
Optional (required if arguments are specified). Specifies
the
for the argument. Each argument name
must be followed with a type definition, even when
specifying several arguments of the same type.
ret_type
Required. Specifies the type of the value the function will
return. In effect, this is the data type of the function.
statement[1,
2...]
Required. The body of code executed within the function;
specifies the actual 'work' done by the function.
62
79
85
93
64
43