Author Topic: Introducing $  (Read 6778 times)

0 Members and 1 Guest are viewing this topic.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 674
  • User-Rate: +27/-1
    • Charles Pegge
Introducing $
« on: August 07, 2007, 05:56:48 PM »
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:

Code: [Select]

$ Hello World!


« Last Edit: August 07, 2007, 06:03:20 PM by Charles Pegge »

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 928
  • User-Rate: +30/-4
    • it-berater
Re: Introducing $
« Reply #1 on: August 07, 2007, 06:31:06 PM »
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 :-).

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 674
  • User-Rate: +27/-1
    • Charles Pegge
Re: Introducing $
« Reply #2 on: August 07, 2007, 08:00:59 PM »
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.

Code: [Select]

"Hello World!"?


this introduces inverted quotes using the left quote mark (ascii 96)

Code: [Select]

new s="World"

$ Hello `s`!


and here are variables expressed in tagged format:

Code: [Select]

new s = "<a> Hello</a>   <b> <1>Earth</1><2>World</2> </b>"

$  `s.a` `s.b.2`!



Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 674
  • User-Rate: +27/-1
    • Charles Pegge
Re: Introducing $
« Reply #3 on: August 08, 2007, 12:08:58 AM »
Built in Parsing:

Code: [Select]

 read("Hello earthlings your World is ours!")
 new w1,w2
 w1=word(); word(); word(); w2=word()

 $ `w1` `w2`!



Functions with default and optional parameters:

Code: [Select]

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



Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 674
  • User-Rate: +27/-1
    • Charles Pegge
Re: Introducing $
« Reply #4 on: August 08, 2007, 06:57:30 AM »
CONTROL STRUCTURES

The minimalist approach:
the only elements available are: {}  if  end if  exit  repeat goto

Loops:

Code: [Select]

new i=0

{
  $ `i`
  if ++i LT 10 then repeat
}


{
  $ `i`
  if  --i LT 1 then exit
 repeat
}



Cases:

Code: [Select]

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
}

« Last Edit: August 08, 2007, 07:01:32 AM by Charles Pegge »

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 674
  • User-Rate: +27/-1
    • Charles Pegge
Re: Introducing $
« Reply #5 on: August 08, 2007, 10:36:31 AM »

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)

Code: [Select]

 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

Code: [Select]

if a then ...
if not a then ...