Tim's Scriptbasic FAQ
================================================================================
Q. How do I know if my firmware includes the Scriptbasic interpreter?

A. To determine whether your Sarian firmware has ScriptBasic, type the following
   command:
 
	bas -v
 
   You should get something like:
 
	Sarian ScriptBasic Revision: 1.0
	ScriptBasic v1.0
	Variation >>STANDARD<< build 30
	Magic value 859009845
	Node size is 16
	Extension interface version is 11
	Compilation: May 25 2006 09:57:24

   If you just get an "ERROR" response, then you don't have it.
================================================================================
Q. What does the following message mean?

	exit at line 552 with code 0

A. This is the normal exit message from the ScriptBasic interpreter
   when it reaches the end of a program or executes a "stop" command.
================================================================================
Q. Comparing a number against a value from the MIB gives incorrect results,
   For example:

	if(100 < mib_val("bas.0.cfg.string1"))then

   is always false.

A. The mib_val function always returns a string value, and the IF interprets it
   as a string. It is necessary to convert the string to a numeric value using
   the "VAL" operator as follows:

	if(100 < val(mib_val("bas.0.cfg.string1")))then
================================================================================
Q. How do I send an SMS from a Basic script?

A. There is a Sarian text command available at the command line interface called
   "sendsms" which has the following syntax (for example):
 
	sendsms 447977997124 "This is a text message"
 
   To do this from inside a Basic script you can use the "system" command as
   follows:
 
	junk = system("sendsms 447977997124 \"This is a text message\"")
 
   Note that double quotes within the string need to be escaped using \.
================================================================================
Q. Can a Basic script access configuration settings?

A. There is a set of general purpose configuration parameters for use by Basic
   scripts. At the command line these are:
 
	basic 0 string<N>
 
   where <N> is 1 ... 30
 
   For example, to set a parameter, type:
 
	basic 0 string1 "447977997124"
 
   The parameters are also available at the web interface under Configure>Basic.
 
   When you save a Sarian configuration, these parameters are saved along with it.
 
   The Sarian has an internal MIB (Management Information Base) which holds the
   parameter values. The Basic MIB variables have the following names:
 
	bas.0.cfg.string<N>
 
   So if you had entered the command:
 
	basic 0 string1 "447977997124"
 
   Then the MIB variable bas.0.cfg.string1 would contain the string
   "447977997124". All of the Basic mib variables can be seen by using the
   command:

	at\mibs=bas
 
   You can get the MIB value from Basic by using the "mib" function. There is a
   function called "mib_val" in one or two of the examples which gives simple
   access to individual MIB variables (see "execute.sb"):
 
	' This function uses the mib() function to read
	' a MIB variable. It then breaks up the resultant
	' string and returns the value of the variable.
	'
	function mib_val(var_name)
	    local a
	    split chomp(mib(var_name)) by "=" to junk, a
	    mib_val = a
	end function

   You can use this to get the value of the "basic 0 string1" value as follows:
 
	str1 = mib_val("bas.0.cfg.string1")
================================================================================
Q.  How do I make a basic script start automatically at boot-up?

A.  cmd 0 autocmd "bas myscript.sb"
    or on the web, Configure>General>Auto Start Macro
================================================================================
