paxJavaScript implements ECMA 262 standard and extends it with the concept of namespace. The main subject of paxJavaScript is the cross-language integration. You can use native JavaScript objects in your paxPascal, paxBasic, and paxC scripts. Inversely, paxScript engine allows you to create instances of paxPascal, paxBasic, paxC, and host-defined classes in your JavaScript scripts.
Another important paxJavaScript features are support of the LISPPA technology and operator overloading.
x = new Object y = new Object y.p = "abc" y.javascript_method = f y.pascal_method = Fact x.prototype = y print x.prototype.p print x.p x.p = 123 print x.prototype.p print y.p print x.javascript_method(2, 3) print y.javascript_method(2, 3) print y.pascal_method(5) print x.pascal_method(5) function f(u, v){ return (u + v) }Fact is a paxPascal-defined function:function Fact(N: Integer): Integer; begin if N = 1 then result := 1 else result := N * Fact(N - 1); end;
G(100, 3.56, 'abc'); function G(x){ print x; for (I=0; I < arguments.length; I++) print arguments[I]; }
w = 'W' x = {'abc': 100, 'pq': 200, 'xyz': 300, 50: 400, w: 500} for (I in x) print I, x[I]
print eval('3 + 2'); x = new Function("x", "return x + x;"); print x(3); y = x; print y(4); z = eval('function f(x, y, z) {return x + y + z;}'); print f(1, 2, 3); print z(4, 5, 6);
var a = new Array(3) a[2] = 12; print a; print a.length; a[5] = 36; print a; print a.length; var d = a.concat([1,2,3]); print d.length; print d; var s = d.join('-'); print s; print d.pop; print d.length; d.push(40, 50); print d; print d.length; d.reverse(); print d; print d.shift(); print d; u = d.slice(2, -1); print u; d.sort(); print d; d.unshift('abc', 'pq'); print d;
var r, re; var s = "The rain in Spain falls mainly in the plain"; re = /ain/i; //Create regular expression pattern. r = s.match(re); //Attempt match on search string. print r;
WordApp = new ActiveXObject("Word.Application"); WordApp.Visible = true; WordApp.Documents.Add(); var Range = WordApp.Documents.Item(1).Range(); Range.Text = "This is a column from a spreadsheet: "; for (I = 0; I < 3; I++) WordApp.Documents.Item(1).Paragraphs.Add(); Range = WordApp.Documents.Item(1).Range(WordApp.Documents.Item(1).Paragraphs.Item(3).Range.Start); Range.Paste()
using StdCtrls, Forms; var F = new TForm(NULL); var B = new TButton(F); F.Show(); B.Parent = F; B.OnMouseDown = MouseHandler; B.Caption = 'Click Me'; function MouseHandler(Sender, Button, Shift, X, Y){ print Sender.Caption; print Button; print Shift; print X; print Y; }