WebRelay-10 Users Manual
Appendix G: BASIC Scripts
Appendix G: BASIC Scripts
BASIC (Beginners All-purpose Symbolic Instruction Code) is a computer programming language that
has been in use for many years. The WebRelay-10 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. The interpreter only supports a small subset of the BASIC commands that are available for
computers. Some non-standard commands have been added, and some commands may function
differently on the WebRelay-10 BASIC interpreter than on other platforms. The following is a short
tutorial on the supported BASIC functions.
Contact customer support if further assistance is required.
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 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.
Comments may be inserted, but must begin with an apostrophe. All text on a line after the apostrophe is
ignored.
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 or literal 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 value 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.
page 95