Dbondb

From Esolang
Jump to navigation Jump to search

Dbondb is an esoteric programming language created by User:Sideshowbob.

Dbondb is derived from Dartmouth BASIC, the first BASIC, which was introduced in 1964. Hence the name, "DB or not DB" (that is the question), with the acronym Dbondb.

Is it still BASIC? Is it an example of making a practical language less practical? Or is it an example of putting more effort into the name than the language?

Variables are lower-case a to z. Data-type is string (treated as float by arithmetic operations)

Statements are separated by semi-colons.

Commands

Statement Purpose
c[text]; comment
d; beginning of the data section
e; end execution
g[label]; go to the label
gs[label]; call a subroutine at the label
?[var][label]; if var is true (non-zero) go to the label, else go to the next statement
i[var]; interactive input, assigned to var
l[text]; label - target for gosub, goto or if
s[var1][const or var2]; assigns const or var2 to var1
+[var1][const or var2]; adds const or var2 to var1, assigns sum to var1
-[var1][const or var2]; subtracts
*[var1][const or var2]; multiplies
/[var1][const or var2]; divides
^[var1][const or var2]; exponentiates
_[var1][const or var2]; concatenates (strings)
pa[ascii code]; prints an ASCII character - e.g.9, 10, etc.
ps[text]; prints a literal string (no quotes)
pv[var]; prints the value of var
r; returns from a subroutine
r0; restores the data pointer to its original location
r[var]; reads the next data item, assigns it to var

Examples

Hello, world!

psHello, World!;pa10;e;

Factorial

psNumber;in;scn;-c1;l;*nc;-c1;?cl;pvn;pa10;e;

Fibonacci sequence

psHow many;ic;sa0;sb1;l;sf0;+fa;+fb;pva;pa10;sab;sbf;-c1;?cl;e;

Area of a circle

psRadius;ir;sar;*ar;*a3.14159;pva;pa10;e;

99 bottles of beer

sn99;l;pvn;ps bottles of beer on the wall, ;pvn;ps bottles of beer.;pa10;psTake one down, pass it around, ;-n1;pvn;ps bottles of beer on the wall;pa10;?nl;e;

Implementation

DBonDB interpreter for Windows