Revision 1.1
WebSwitch™ Users Manual
Appendix G: BASIC Scripts (Model XRDI-WS3P only)
BASIC (Beginners All-purpose Symbolic Instruction Code) is a computer programming language that
has been in use for many years. This ControlByWeb™ product has an integrated BASIC interpreter for
simple BASIC scripts. This provides a great deal of flexibility by allowing users to customize basic
functions of the unit. Note that the interpreter only supports a small subset of the BASIC commands that
are available for computers. Note also, that some non-standard commands have been added, and some
commands may function differently on the ControlByWeb™ BASIC interpreter than on other platforms.
The following is a short tutorial on the supported BASIC functions. This tutorial is not meant as a tutorial
for using the BASIC programming language and it assumes the user has already had some experience
with programming. For more information on programming in BASIC, tutorials can be found on the
Internet.
Structure
A BASIC script is written as a .txt file, which is then uploaded to the device using the
Script
setup tab.
The maximum script size is 2K bytes. Each line within the script contains a single statement. Line
numbers are not used. Statements are not case sensitive; however, variables are. IF THEN, FOR loops,
and DO loops can only be nested up to 5 times per command. For those not familiar with nesting, the
following is an example of nested FOR loops:
FOR a = 0 to 100
FOR b = 0 to 100
NEXT b
NEXT a
Every program must end with an END statement. Subroutines would then follow after the the END
statement, if required. The last line of the script should be left blank.
Line Format
Every line follows the same format. The basic format is:
statement (variable) (=, <, >, <=, >=, <>) (expression) (THEN)
The fields in parentheses are optional depending on the statement. Spaces must be used between all
statements, numbers, variables, operators, expressions, etc. Multiple spaces are valid.
Examples:
LET a=1
'this will return an error because of insufficient spacing
LET a = 1
'this is valid
LET a = 1
'this is valid
Only a single variable is allowed on the left side of any operator. The following example is incorrect and
will return an error. The error occurs because there is more than a single variable to the left of the
comparison operator (a + 2 is to the left of =).
IF a + 2 = 3 THEN 'this will return an error
To fix the above line, replace 'a + 2.' One of the following options may be used:
IF a = 1 THEN
...or...
LET b = a + 2
IF b = 3 THEN
Xytronix Research & Design, Inc.
98