$# (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.:
|run||Used to execute an external program as follows:
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:
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
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!!!|
for i=1 to 10 print i for countdown=10 to 1 step -1 print countdown
for i=1 to 10 begin print i print i*2 print i*3 end
#nested for loops for i=1 to 3 for j=1 to 3 begin print i,j end for i=1 to 10 begin print i for j=1 to 10 print j end
print "hello" print " world!"Gives output:
hello world!But when using a semi-colon the newline is ommitted:
print "hello"; print " world!"Gives output:
This comes in handy for instance when reading user input with the input function. For instance asking a user a number and printing the square root will go like this:
print "Give a number for x:"; input x print "The square root of x=", sqrt( val(x) )
We see that print statement allows comma seperated expressions and these will be concatenated. The first print statement has a semicolon so it ommits the newline.Add more text here .....
To get the latest cvs snapshot you have to execute the following lines in a bash prompt. When prompted for a password for anonymous, simply press the Enter key :
cvs -d:pserver:email@example.com: /cvsroot/wsbasic login cvs -z3 -d:pserver:firstname.lastname@example.org: /cvsroot/wsbasic co wsbasic