Results 1 to 9 of 9

Thread: Where can I get a proper JavaScript host for VB6?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,105

    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

  2. #2
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    711

    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.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,105

    Re: Where can I get a proper JavaScript host for VB6?

    Quote Originally Posted by dz32 View Post
    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

    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.

  4. #4
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    711

    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.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,105

    Re: Where can I get a proper JavaScript host for VB6?

    Quote Originally Posted by dz32 View Post
    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?

  6. #6
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    711

    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.

  7. #7
    Frenzied Member
    Join Date
    Jan 2020
    Posts
    1,704

    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

  8. #8
    Frenzied Member
    Join Date
    Jan 2020
    Posts
    1,704

    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=

  9. #9
    Fanatic Member
    Join Date
    Aug 2020
    Posts
    795

    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
  •  



Click Here to Expand Forum to Full Width