59
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
A locally defined variable with the same name as a global variable takes
precedence in its context over any variable with the same name which is defined in
a 'wider' scope.
Local variable names also take precedence over procedure names. For example:
sub
prc1(x
as
byte
)
'some code here
end
sub
sub
prc2
dim
prc1
as
byte
'define a local variable with the same name as one
procedure we have
prc1=0
'this will generate no error -- in the current scope prc1 is a
variable
prc1(2)
'here, we try to invoke sub prc1 and this will cause a compiler
error.
end
sub
HTML Scope
This section applies only to platforms which include an HTTP server.
This is a special scope, implemented in Tibbo Basic. HTML files included within a
project may contain embedded Tibbo Basic code. This code is executed when the
HTTP server processes an HTTP GET (or POST) request. Statements within an
HTML file are considered to be within one scope -- similarly to a function or sub
scope, with the exceptions that
and
statements are
allowed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<BODY>
BEGINNING OF OUTPUT<br>
<?
include
"global.tbh"
declare
i
as
integer
' i is defined somewhere else
for
i =
1
to
10
?>
<i> Foo </i>
<?
next
i
?>
<br>END OF OUTPUT<br>
</BODY>
</HTML>
Designing dynamic HTML pages always presents you with a choice: what to do-
include the BASIC code right into the HTML file or create a set of subs and
functions and just call them from the HTML file? In the first place you put a lot of
BASIC code into the HTML file itself, in the second case you just call subs and
90
79