THE WSBASIC SCRIPTING LANGUAGE


1. Licence
2. What is Wsbasic
3. How Wsbasic works
4. Language elements
4.1 Special elements and keywords
4.2 Variables
4.3 Control structures
4.4 Logical operators
4.5 Arithmetic operators
4.6 Functions
4.7 Input and output
4.8 Keywords and reserved terms
5. Examples
6. Bug reports
7. Contacts
8. Download

1. Licence


Wsbasic was developed and is currently maintained by Walter Schreppers. He has made it available to the public for unrestricted non-commercial use under the terms of the GNU licence. No warranty, neither explicit nor implied, is given as to Wsbasic's suitability or performance in any context, and the author reserves the right, in subsequent releases of Wsbasic, to modify elements of the application as circumstances may warrant.

2. What is Wsbasic


Wsbasic is a console-based scripting interpreter used for developing small applications and utilities in Unix/Linux environments. It provides basic facilities  for computer scripting and includes elements such as variables, functions, arithmetic and logical operators, control statements and external calls. Its keywords and syntax are largely reminiscent of the well-known computer language basic. Since bash syntax can appear complicated or confusing to many users, Wsbasic provides an alternative means to bash for writing console-based scripts, using keywords and a syntax that will be familiar to many.

3. How Wsbasic works

Wsbasic can be invoked in two ways:
  1. from the command line of a traditional Unix/Linux shell, or
  2. via a script that contains the Wsbasic command as the first line in a script (i.e. by means of the Unix/Linux "shebang").

Invocation from the command line is accomplished as follows:

wsbasic scriptname.b

Invocation from a script is accomplished as follows (i.e. from the first line of the script containing the full path to the Wsbasic program):

#!/usr/local/bin/wsbasic

4. Language elements

Wsbasic comprises the following elements and keywords:

4.1  Special elements and keywords

Element/Keyword Description

$# (and $0, $1, $2 ... $n)
Used to retrieve command line parameters. The $# combination retrieves the entire command line. Individual command line parameters are retrieved via $0 to $n. $0 retrieves the full name and path of the Wsbasic interpreter and $1 retrieves the name of script being executed. All following elements refer to command line arguments passed to the actual script. 
# Used for comments (comments can also appear on the same line as a valid Wsbasic statement, following the statement).
#! Used in the first line of a Wsbasic script. This combination of characters, known as the Unix "shebang", appears before the full path name of the Wsbasic executable, e.g.:

#!/usr/local/bin/wsbasic
run Used to execute an external program as follows:

run(x)

where x is either a string variable containing the name of the program and optional parameters or an actual string, surrounded by double quotes, containing the program name and optional parameters.
input Used to read keyboard input from user:

input x

where x is any variable name. The given user input is assigned to x as a string. You can however convert it to a number by using the val function. Mind that with run braces are needed and with input they have to be ommitted (next version of wsbasic will probably allow both).
sin, cos, exp, log Compute mathematical sinus, cosin, exponential and log

sin(x)

where x is a number variable containing a value. The result is returned as a number as well (all numbers are '64 bit double' ). Similarly cos, exp and log can be used...
begin, end, while, if, else, print, input, for, to, step, and, or, not, return, break, write, left, mid, right, len, asc, chr, ran, read, restore, data, foreach, in, seperated, by, function, mod, sqrt, str, val, todo... explain these remaining keywords!!!

4.2 Variables


Wsbasic is a weakly typed language. There is generally no need to declare a variable before using it, although this is good programming practice and will make your own scripts more transparent, understandable and maintainable.

Add more text here .....

4.3 Control structures

If, for, foreach, while are already supported. We give short examples of each.