-
May 24th, 2022, 03:12 PM
#1
Thread Starter
Frenzied Member
Where can I get a proper JavaScript host for VB6?
I can't use the Microsoft Script Control component, because its only support for JavaScript, is Microsoft's own version called JScript, which is missing a LOT of functionality normally found in proper JavaScript host implementations (such as web browsers). JScript, for example, is missing the JSON object that JavaScript has for parsing JSON data files. I want to write a program that will have scripting features for extensibility, and I want to use JavaScript for those scripting features. Is there any 3rd party component that was ever made, that actually properly implements JavaScript, so that I can use JavaScript in the VB6 program I'm writing?
Last edited by Ben321; May 24th, 2022 at 04:35 PM.
Reason: corrected name of Microsoft provided component
-
May 24th, 2022, 03:28 PM
#2
Re: Where can I get a proper JavaScript host for VB6?
Duktape: https://www.vbforums.com/showthread....ghlight=Duk4vb
You don’t need the full ide and debugger component to use it. You can just use the class to access the script engine directly:
https://github.com/dzzie/duk4vb/wiki/Examples
Last edited by dz32; May 24th, 2022 at 03:32 PM.
-
May 24th, 2022, 04:37 PM
#3
Thread Starter
Frenzied Member
Re: Where can I get a proper JavaScript host for VB6?
Originally Posted by dz32
But I do need to compile it. That github does NOT provide a downloadable OCX or ActiveX DLL file. The ActiveX component provided there is C source code. I don't know how to compile C projects of this complexity. I only have ever had experience compiling simple projects, where the one or two C files were all in the same folder. Things usually break down for me with C when the the code is more complicated, especially if it has any external dependencies that need to be downloaded from other sources and then compiled before the main code that I'm trying to compile.
I'm looking for a downloadable component that has already been compiled, and will provide the functionality I'm looking for.
-
May 24th, 2022, 05:45 PM
#4
Re: Where can I get a proper JavaScript host for VB6?
there are binaries in the git repo. Duk4VB.dll in the top level folder is the javascript engine
vb_examples/basic and vb_examples/with_com only depend on this standard dll (like winapi dlls)
the full ocx with debugger and IDE is in vb_examples/full_ocx with a compiled ocx and /dependencies
this is all done in vb6
i do have an installer with all the dependencies for a tool which uses this package:
http://sandsprite.com/CodeStuff/IDAJS_2_Setup.exe
Last edited by dz32; May 24th, 2022 at 05:50 PM.
-
May 24th, 2022, 07:36 PM
#5
Thread Starter
Frenzied Member
Re: Where can I get a proper JavaScript host for VB6?
Originally Posted by dz32
there are binaries in the git repo. Duk4VB.dll in the top level folder is the javascript engine
vb_examples/basic and vb_examples/with_com only depend on this standard dll (like winapi dlls)
Where can I find the function reference manual for this DLL?
-
May 25th, 2022, 12:13 AM
#6
Re: Where can I get a proper JavaScript host for VB6?
https://duktape.org/
The vb6 CDucktape.cls will be your main access point
To the c dll if using just the script engine
https://github.com/dzzie/duk4vb/blob...M/CDukTape.cls
If you want to use the full ide/debugger then you would use
The duk4vb.ocx
https://github.com/dzzie/duk4vb/blob...x/ucDukDbg.ctl
I do not have documentation on how to use it other than code examples.
I searched all over and didn’t find anything made for vb so had to write this. I’ve been happy with it. It’s doing everything I needed. I haven’t had to go back into the c side at all.
The guts of the ocx are complex but it’s all open source including the ide editor component which is its own
Vb6 ocx and another c dll.
Just the cduktape.cls with direct access to just the js engine is pretty straight forward and should be easy to use. The mechanism to .addobject to access vb6 forms and classes is complex and requires a JavaScript class wrapper. There is a bindings generator that can help but you will have to study the vb6 source to understand it.
The ms script control did some great magic behind the scenes to make their addobject so seamless. I don’t have the time to match that so had to go with an extra manual step.
If you don’t need com support the /basic example if the smallest easiest way to dip your feet in.
https://github.com/dzzie/duk4vb/blob...c/CDukTape.cls
Code:
Private Sub Command1_Click()
Dim rv
Dim duk As CDukTape
List1.Clear
Set duk = New CDukTape
duk.Timeout = 7000 'set to 0 to disabled
Me.Caption = "Running..."
rv = duk.Eval(Text1.text)
Me.Caption = "Complete."
If duk.hadError Then
MsgBox "Error: " & duk.LastError
Else
If Len(rv) > 0 And rv <> "undefined" Then MsgBox "eval returned: " & rv
End If
Set duk = Nothing
End Sub
The examples will have to guide you though there is a lot to understand I can’t really offer support on it.
I am not aware of any alternatives.
Last edited by dz32; May 25th, 2022 at 12:28 AM.
-
May 31st, 2022, 06:43 AM
#7
Re: Where can I get a proper JavaScript host for VB6?
XiaoYao Json Class by ScriptControl 【very interesting】-VBForums
https://www.vbforums.com/showthread....%3B&highlight=
Code:
JsCode = "var JSON=function(){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','""':'\\""','\\':'\\\\'},s={'boolean':function(x){return String(x)},number:function(x){return isFinite(x)?String(x):'null'},string:function(x){if(/[""\\\x00-\x1f]/.test(x)){x=x.replace(/([\x00-\x1f\\""])/g,function(a,b){var c=m[b];if(c){return c}c=b.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16)})}return'""'+x+'""'},object:function(x){if(x){var a=[],b,f,i,l,v;if(x instanceof Array){a[0]='[';l=x.length;for(i=0;i<l;i+=1){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=','}a[a.length]=v;b=true}}}a[a.length]=']'}else if(x instanceof Object){a[0]='{';for(i in x){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=','}a.push(s.string(i),':',v);b=true}}}a[a.length]='}'}else{return}return a.join('')}return'null'}};return{"
JsCode = JsCode & "copyright: '(c)2005 JSON.org',license:'http://www.crockford.com/JSON/license.html',stringify:function(v){var f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){return v}}return null},parse:function(text){try{return!(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/""(\\.|[^""\\])*""/g,'')))&&eval('('+text+')')}catch(e){return false}}}}();"
JsLib.AddCode JsCode
-
May 31st, 2022, 06:44 AM
#8
Re: Where can I get a proper JavaScript host for VB6?
can use chrome or edge,or chrome core.dll for script:
Fast Json by Chrome V8,How to StrToUtf8,Utf8 TO Unicode STR?-VBForums
https://www.vbforums.com/showthread....STR&highlight=
-
May 31st, 2022, 07:10 AM
#9
Re: Where can I get a proper JavaScript host for VB6?
RC5/RC6 is the best JavaScript host for VB6 I've seen so far.
I have a lot of JS interacting with VB6 in my projects, and it's all done by RC5/RC6, which works unbeatable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|