JSDB     Home    License    Download    Tutorial    Reference    Projects    Feedback    History
[ English | français ]

Exploring JSDB

js>1+4
5
js>writeln("hello, world")
hello, world

Variables

js>var a = 100000;
js>var b = 2000;
js>a / b
50
js>typeof a
number
js>var c = "Hello";
js>typeof c
string

Structures

js>me = {name: 'Shanti', home: 'California'};
js>writeln(me.name)
Shanti
js>writeln(me.name," lives in ",me.home);
Shanti lives in California
js>f = [1,1,2,3,5,8,13,21];
js>for (var i in f) writeln(f[i])
1
1
2
...

Streams

Stream is a built-in object. Stream objects can represent files, TCP sockets, web pages, RS-232 ports, pipes, and dynamically allocated blocks of memory.

js>var s = new Stream('jsdbhelp.html')
jsdbhelp.html
js>s.readFile()
<head>
<title>JSDB Help</title>
...
js>quit

XML

js>
js>run('perfect.js')
...
js>load("xml.js")
js>x = readXML(new Stream('test.xml'));
js>items = x.find('item');
js>for (var i in items) writeln(items[i].cdata);
...

Writing programs

Create a .js file using your favorite text editor. Run it with one of

jsdb.exe program.js

jsdb.exe -load xml.js program.js

Standalone JSDB programs

c:\temp>pkzip program.zip main.js
c:\temp>copy /b jsdb.exe+file.zip program.exe c:\temp>program.exe

Debugging programs

There are two interactive debuggers, debugconsole.js and debug.js.

c:\temp>jsdb debug.js
localhost:8832
c:\temp>jsdb.exe -debug localhost:8832 myprogram.js

Or, more conveniently,

c:\temp>jsdb debug.js myprogram.js

Next

The JSDB cookbook