This is an experimental script. Well actually it goes back quite a long way - to around 1988, compiled with Turbobasic. But this is a minimalist version which I use for exploring various ideas and syntaxes.
The Zip file attached below includes:
A binary for Linux - $.
A binary for MS - $.exe
Source Code in FreeBasic - $.bas
Apart from minor fixes I won't be making significant alterations to this version.
'$' can be run from windows or the console. Its default output is to a file called log.txt and it always looks for a program called main.pro.
My plan, after making the gentlest of introductions, is to demonstrate its use by translating its source code back into PowerBasic, therebye developing a useful tool at the same time.
I also have a benchmark application for designing domes, which exercises most of its features, (and me!), generating X3D scripts for 3D visualisation, and design data.
But first the hello program:
$ Hello World!
Its said that all big things start with a dream.
And most of them also start with enough $'s :-).
Lets see how your small $ will develope, and if i becomes big.
Even if not, it already looks funny.
Until now I knew only Dogs called "Dollar", now a small programm has that name :-).
Well I thought of calling it $n but thought that might be too long.
Here are some more "Hello World"s:
the '?' is primarily used in debugging.
"Hello World!"?
this introduces inverted quotes using the left quote mark (ascii 96)
new s="World"
$ Hello `s`!
and here are variables expressed in tagged format:
new s = "<a> Hello</a> <b> <1>Earth</1><2>World</2> </b>"
$ `s.a` `s.b.2`!
Built in Parsing:
read("Hello earthlings your World is ours!")
new w1,w2
w1=word(); word(); word(); w2=word()
$ `w1` `w2`!
Functions with default and optional parameters:
greet() | Hello World!
greet("Greetings") | Greetings World!
greet( ,"friend") | Hello friend!
greet(person="my friend") | Hello my friend!
function greet(hail="Hello",person="World")
$ `hail` `person`!
end function
CONTROL STRUCTURES
The minimalist approach:
the only elements available are: {} if end if exit repeat goto
Loops:
new i=0
{
$ `i`
if ++i LT 10 then repeat
}
{
$ `i`
if --i LT 1 then exit
repeat
}
Cases:
new i=0
// loop
{
// case block inside this loop
{
if i EQ 1 then
$ one
exit
end if
if i EQ 2 then
$ two
exit
end if
$ `i` // case else
}
i++
if i LT 3 then repeat
}
Conditionals
Pointy brackets are reserved exclusively for markup tags, abolishing their use in Greater-Than and Less-Than. In addition to this the Equals sign is only used for assignments, never for comparison.
These operators are replaced by these words (always in uppercase)
LT | < Less than
LE | <= Less than or Equal
EQ | = Equal to
NE | <> Not equal to
GE | >= Greate than or Equal to
GT | > Greater than
if a EQ b then b=a+1 // note the 2 different kinds of equals.
True and False
String variables can be also directly used in comparisons.
Any viariable van be used as a logical entity:
A zero valued number or an empty string are taken to be FALSE.
Every other value is take as TRUE
TRUE may be made FALSE and vice-versa by using the not operator
if a then ...
if not a then ...