Sarian Basic Interpreter
========================

This kit contains the following sub-folders:

    doc      - contains the Basic reference manual and the
               1 wire API specification
    examples - various basic examples
    1wire    - 1 wire support library and examples

Running a basic script
----------------------

To run a basic script, use the command:

bas <filename>

Where <filename> is a file containing the basic script.

A number of example scripts are available and are described in other
"readme.txt" files. These scripts can be loaded onto the Sarian and executed
using the "bas" command.

File handling
-------------
Files can either be opened for reading, writing or appending.
When opened for writing, a RAM file is created and the contents are
stored in RAM buffers. When opened for appending, data is added to the
end of an existing RAM file, or a new RAM file is created.
RAM files may be permanently saved to flash by copying or moving them
to a flash file. From a Basic script this may be done using the "system"
command, for example:

	result = system("copy ramfile.txt ffile.txt")

A RAM file must be closed before before being copied or deleted.
All RAM files are closed when a script terminates.
See the example "newfile.bas" for an example of how to create a
simple file and save it to flash.

Serial port I/O
---------------

Scripts may read from or write to serial ports - see the examples
described below. To do both input and output, you must use separate
open commmands, one for reading and one for writing. See the examples
rdlines.bas and rwasy.bas for examples of this.

The basic interpreter is not designed to run interactively at the
command prompt, although the standard PRINT command may be used
to write to the command line interface. To read from a serial port
it must be explicitly opened - see the example rdlines.bas.

Kill command
------------

To stop a basic script running, use the command:

basic 0 kill

MIB Variables
-------------

In addition to the normal Sarian MIB, two sets of MIB variables are
available specifically for use by basic scripts.

The first set of MIB variables are general-purpose strings which may
be used by a script to set various data values specific to an application.
These MIB variables have the following names:

    bas.0.userstring<n>

Where <n> is a number in the range 1 to 15.

The main purpose of these variables is to allow them to be displayed or
processed on a web page. The Sarian web server provides a built-in
Javascript function "mib" for accessing MIB variables. See the
file weather1.asp for an example of its use. Basic scripts can read
and set these variables using the "mib" and "mibset" functions.

Another set of MIB variables is designed to allow a basic script
access to a number of configuration parameters. These parameters
are set in the same way as other Sarian parameters, and saved in
the Sarian's configuration files (config.da0 or config.da1).
These MIB variables have the following names:

    bas.0.cfg.string<n>

Where <n> is a number in the range 1 to 5.

For example, if your configuration (config.da0) has the line:

    basic 0 string1 "file.txt"

Then the MIB variable bas.0.cfg.string1 will contain the string "file.txt".

The Sarian includes a web page (Configure>Basic) to allow these parameters
to be changed and saved. This development kit also contains a sample web page
(mybascfg.asp) which illustrates the use of these configuration parameters
and may be tailored to suit specific applications. At the commmand line
interface the parameters may be displayed by using the "basic" command,
for example:

	basic 0 ?
	Parameters are..
	   string1: This is the value of string one
	   string2: This is the value of string two
	   string3: This is the value of string three
	   string4: This is the value of string four
	   string5: this is parameter 5
	OK

To change the value of a parameter use the command in the format:

	basic 0 <parameter> <value>

Where <parameter> is string<n> and <n> is a number in the range 1 to 5.



Example files
-------------

Example basic scripts may be found in the examples subfolder.
See the readme.txt file in that folder for a description of these.

1-WIre Library
--------------

The Basic 1-Wire support library is in the folder called 1wire. This contains two
sub-folders as follows:

lib      - the 1-Wire library
examples - example scripts which use the 1-Wire library

See the readme files in these folders for a description of the files.

1-Wire port configuration
-------------------------

The 1-Wire port is the expansion port (marked EXP) on the Sarian. On the
MR2110 this is ASY2. On other models it is ASY3. Normally the EXP port
will be factory configured for correct operation. If necessary, the following
commands may be used to manually configure the expansion port (for models other than
the MR2110):
 
    at\port=3
    ate0
    atq1
    at&w
    at\port
    cmd 3 cfilton on
    config 0 save
 
You should then reboot the unit.

