Hi guys, thought i would share a project I have been working on.
I wanted to find a newer javascript engine that I could use with vb6. All in all the MS script control is very capable and easy to use, but it has some nuances that makes it not work with some javascript and does not support all newer constructs. Also there is no built in debugging support unless you try to host the IActiveScript interfaces yourself. (i never could get the debug interfaces working with vb6 either)
I started looking around and found the duktape javascript engine and got it working with vb6. I also devised a way to give the scripts access to COM objects.
An example use could be as simple as:
Below are my current supported test cases:
Its not as automatic as the MS script control, you do have to generate JS class wrappers for the COM object you want to use, but there is also a generator for it. In the future this stage could be automated but not yet.
This project is at a good point right now and generally usable so thought I would share at this point.
https://github.com/dzzie/duk4vb
The duktape engine also supports a debugger protocol, which is going to be my next step.
I wanted to find a newer javascript engine that I could use with vb6. All in all the MS script control is very capable and easy to use, but it has some nuances that makes it not work with some javascript and does not support all newer constructs. Also there is no built in debugging support unless you try to host the IActiveScript interfaces yourself. (i never could get the debug interfaces working with vb6 either)
I started looking around and found the duktape javascript engine and got it working with vb6. I also devised a way to give the scripts access to COM objects.
An example use could be as simple as:
Code:
Dim duk As New CDukTape
msgbox duk.Eval("1+2")
Code:
' js = "1+2"
' js = "alert(1+2)"
' js = "while(1){;}" 'timeout test
' js = "prompt('text')"
' js = "a='testing';alert(a[0]);"
'------------- vbdevkit tests ---------------------
' js = "fso2.ReadFile('c:\\lastGraph.txt')"
' js = "alert(dlg.OpenDialog(4))"
' js = "pth = dlg.OpenDialog(4,'title','c:\\',0); fso2.ReadFile(pth)"
'--------------------------------------------------
' js = "form.Text1.Text = 'test'"
' js = "form.Text1.Text + ' read back in from javascript!'"
' js = "form.caption = 'test!';alert(form.caption)"
' js = "for(i=0;i<10;i++)form.List2.AddItem('item:'+i);alert('clearing!');form.List2.Clear()"
' js = "var ts = fso.OpenTextFile('c:\\lastGraph.txt',1,true,0);v = ts.ReadAll(); v" 'value of v is returned from eval..
' js = "var ts = fso.OpenTextFile('c:\\lastGraph.txt',1); v = ts.ReadAll();alert(v)" '(default args test)
This project is at a good point right now and generally usable so thought I would share at this point.
https://github.com/dzzie/duk4vb
The duktape engine also supports a debugger protocol, which is going to be my next step.