
ARMweb
allows for basic code to be embedded in the web pages much like PHP or JavaScript
Variables may be accessed from the User program. The
intention is not to place your BASIC code in this program, but to interact with
your program from a webpage. For example if you put an endless loop in the BASIC
embedded in the webpage, the webpage will hang.
Example: Add reading a
User variable through the webpage.
Here is a modified version of the webpage loaded from Web Services .
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>simple page</title> </head> <body> <?BASIC
print "the VALUE of y is ";y ?> <br> <br> <img style="width: 500px; height: 80px;" alt="planes" src="banner1.gif"><br> </body> </html>
Now from Code page of ARMweb enter the following program (its can be accessed at armweb.htm)
WHILE 1
IO(15) = Y
AND 1 ' Flash the LED
Y = Y +
1
WAIT
1000
LOOP
RUN
The program is running and the value of Y is incremented every half second.
Browse to http://ARMweb/simple.htm
Refreshing the browser will show the updated values of Y.
Example: Executing a BASIC command from a webpage.
To the above example we will add a method to set the
variable y to 0, by accessing another webpage that runs a BASIC program.
This may also be accomplished with CGI, see the CGI
examples
.
First add an anchor to another webpage that will be served by the ARMweb
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN">
<html>
<head>
<meta content="text/html;
charset=ISO-8859-1" http-equiv="content-type">
<title>simple page</title>
</head>
<body>
<?BASIC
print "the VALUE of y is ";y
?>
<br>
<br>
<img style="width: 500px;
height: 80px;" alt="planes" src="banner1.gif">
<a
href="zero.htm">Zero Y</a>
</body>
</html>
Next create another page zero.htm that executes a very short BASIC program to zero the variable y. This page also returns to the original page.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">Some notes, currently errors in the BASIC embedded in HTML are not flagged, so be careful, but they will be visible to the console of BASICtools over the USB connection.
The meta tag highlighted will return you to the original page after 1 second, though not all browsers support this.
For a CGI method to accomplish the same see the CGI examples .
WEB BASIC limits
The BASIC code between <?BASIC and ?> is limited to 1450 characters.
The output from a web BASIC program must not exceed 1460 characters.
If the web BASIC contains an infinite loop, the server will hang waiting for the loop to complete.
The Pre-processor is not available to WEB BASIC inside the HTML. That includes #include, #ifdef, #define...
The code between <?BASIC ... ?> and the output is also sent to the UART0 (and via USB Dongle to BASICtools). This slows down the web server, that can be improved by increasing the baud rate of UART0, by executing BAUD0(937500) in your main program. And to continue to view those debug messages reset the baud rate in BASICtools.