Results 1 to 13 of 13

Thread: Can RC6-ActionScript use a non-IE engine when parsing JS?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Can RC6-ActionScript use a non-IE engine when parsing JS?

    In 2020, I wrote a WebBuilder tool in VB6 and RC6, which was developed on XP and used a lot of open source JS libs, all the development work was completed, and it was tested on Win10 and worked well. Later, due to the coronavirus pandemic, the project was kept in a drawer for 2 years. Now that I don't have XP computers。In recent days, when I opened the project on my Win10 computer, I found that many JS libs could not be parsed by RC6.ActionScript. My guess is that the version of the IE-Engine on my Win10 computers is too low.

    The IE version I got with cIEFeatures.InstalledVersion is 11.156. Also, Also, I handle the interaction between VB6 and JS via cJSWrap:

    cJSWrap
    Code:
    Option Explicit
     
    Private mDoc As Object
    
    Private Sub Class_Initialize()
      Set mDoc = CreateObject("htmlfile")
    End Sub
    
    Public Sub AddSriptContent(JavaScript As String)
      AddElmtToHead CreateScriptElmt(JavaScript)
    End Sub
    
    Public Function Func(FuncName As String, ParamArray P()) 'for max 5 Params currently
      Select Case UBound(P) + 1
        Case 0: Func = CallByName(mDoc.Script, FuncName, VbMethod)
        Case 1: Func = CallByName(mDoc.Script, FuncName, VbMethod, P(0))
        Case 2: Func = CallByName(mDoc.Script, FuncName, VbMethod, P(0), P(1))
        Case 3: Func = CallByName(mDoc.Script, FuncName, VbMethod, P(0), P(1), P(2))
        Case 4: Func = CallByName(mDoc.Script, FuncName, VbMethod, P(0), P(1), P(2), P(3))
        Case 5: Func = CallByName(mDoc.Script, FuncName, VbMethod, P(0), P(1), P(2), P(3), P(4))
      End Select
    End Function
    
    Public Property Get Prop(PropName As String)
      Prop = CallByName(mDoc.Script, PropName, VbGet)
    End Property
    Public Property Let Prop(PropName As String, PropValue)
      CallByName mDoc.Script, PropName, VbLet, PropValue
    End Property
     
    Private Sub AddElmtToHead(Elmt)
      mDoc.GetElementsByTagName("head").Item(0).appendChild Elmt
    End Sub
    Private Function CreateScriptElmt(ScriptText As String)
      Set CreateScriptElmt = mDoc.createElement("script")
          CreateScriptElmt.Type = "text/javascript"
          CreateScriptElmt.Text = ScriptText
    End Function
    ===================================================================================


    My questions are:

    (1) RC6.ActionScript(VBScript and JScript) can only use IE engine when parsing JS?

    (2) The following statements are used in cJSWrap:

    Set mDoc = CreateObject("htmlfile")

    This means that cJSWrap use MS.HTMLDocument to process JavaScript.

    Does HTMLDocument limit cJSWrap to only using the IE engine?


    (3) Can cJSWrap be upgraded to use WebView2(Edge-Chromium)? That said, I'd like to handle JS through WebView2(Edge-Chromium) of RC6, not the outdated IE-Kernel.

    (4) How to improve the version of IE engine, do I need to install an old version of MiscroSoft Edge? Is IE11 the highest version of the IE kernel?

    Thanks.
    Last edited by SearchingDataOnly; Jun 1st, 2023 at 06:09 AM.

  2. #2
    Lively Member
    Join Date
    Sep 2016
    Location
    Germany, Bavaria
    Posts
    75

    Re: Can RC6-ActionScript only use IE Engine when parsing JS?

    Because I'm interested in that, too: I have successfully tested your code with simple JavaScript on W7, W10 and W11.

    Under WebView2 I see a problem: The way I got to know the RC6 WebView, it needs a UI to work. This could possibly be implemented with an invisible form. And even then this form must be visible at least when instantiating the WebView. I think your request is not feasible in the current form. But if Olaf is already further along, I'm looking forward to it. W. Wolf

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Re: Can RC6-ActionScript only use IE Engine when parsing JS?

    Yes, WebView requires a UI to work, which is a troubling problem.

    Here's the JS code that doesn't parse on my computer:

    Code:
    Option Explicit
    
    Private WithEvents mSC As cActiveScript
    Private mCO As Object
    
    Private Sub Form_Load()
        Dim sCode As String:        Dim sFunction As String
        Dim sSource As String
        
        Set mSC = New_c.ActiveScript("JScript9", False, False)
        
        '--- Code come from svelte ---
        With New_c.StringBuilder
            .AddNL "function maybeInvokeDelegate(delegate, context) {"              
            .AddNL "    var method = delegate.iterator[context.method];"
            .AddNL "    if (method === undefined) {"
            .AddNL "      if (context.method === ""throw"") {"
            .AddNL "        if (delegate.iterator.return) {"
            .AddNL "        }"
            .AddNL "      }"
            .AddNL "      return ContinueSentinel;"
            .AddNL "    }"
            .AddNL "}"
    
            sSource = .ToString()
            
        End With
            
        mSC.AddCode sSource
        Set mCO = mSC.CodeObject
        
    End Sub
    
    Private Sub mSC_error(Description As String, ByVal LineNr As Long, ByVal CharPos As Long)
        If Len(Description) Then
            MsgBox "Error in Line: " & LineNr & " - Pos: " & CharPos & " -> " & Description
        End If
    End Sub
    
    Private Sub Form_Initialize()
        'IEF.FEATURE_BROWSER_EMULATION = Val(IEF.InstalledVersion)       'Init the extended features of the IE-Engine for this Process
    End Sub
    The unparseable line of code is:
    Code:
        if (delegate.iterator.return) {
    Last edited by SearchingDataOnly; Apr 20th, 2023 at 08:51 AM.

  4. #4
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Can RC6-ActionScript only use IE Engine when parsing JS?

    Quote Originally Posted by SearchingDataOnly View Post
    The unparseable line of code is:
    Code:
        if (delegate.iterator.return) {
    JScript(9) probably parses and recognizes any occurence of "return" as a "hard keyword"...
    though since js allows property-access also via String-Literal in square-brackets,
    one could write the whole thing also this way (to make the error go away):

    Code:
        With New_c.StringBuilder
            .AddNL "function maybeInvokeDelegate(delegate, context) {"
            .AddNL "    var method = delegate.iterator[context.method];"
            .AddNL "    if (method === undefined) {"
            .AddNL "      if (context.method === 'throw') {"
            .AddNL "        if (delegate.iterator['return']) {"
            .AddNL "        }"
            .AddNL "      }"
            .AddNL "      return ContinueSentinel;"
            .AddNL "    }"
            .AddNL "}"
    
            sSource = .ToString()
        End With
    As for accessing the V8-js-engine in Chromium-based WebView2 -
    the interaction with the VB-side works only via "OutOfProcess-COM-marshaling" -
    whereas the ActiveScripting-interfaces of cActiveScript allow InProcess-interaction with the supported Interpreters.

    So, "highfrequent calls" (between VB6 and WebView2-js) are not recommended (due to higher latencies in the COM/OLE-transport mechanism).

    The "visibility-requirement" I'd not consider a larger problem...
    since in your shoes, I'd implement "most of the IDE-GUI" inside the WebView2 anyways
    (as e.g. Wayne does with the TwinBasic-IDE)... including a decent js-based Editor-Widget like e.g. Monaco.

    Olaf

  5. #5
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Can RC6-ActionScript only use IE Engine when parsing JS?

    how to set Webjs TypeName?
    Dim WebJs As ??


    maybe htmljs can support websocket client
    I've improved the code so that variables are forced to specify types for better run-time
    v8js.dll maybe 5-20mb size,only for js,without rc6.dll,webview2Load.dll,sqlite.dll

    Code:
    Private Declare Function rtcCallByName Lib "msvbvm60" ( _
                             ByRef vRet As Variant, _
                             ByVal cObj As Object, _
                             ByVal sMethod As Long, _
                             ByVal eCallType As VbCallType, _
                             ByRef pArgs() As Variant, _
                             ByVal lcid As Long) As Long
    Dim WebJs As Object, mDoc As HTMLDocument
    'typename(WebJs)=HTMLWindow2 [Object Window]
    '
    Private Sub Class_Initialize()
      Set mDoc = CreateObject("htmlfile")
      Set WebJs = mDoc.Script
    End Sub
    
    
    Public Function Run(FuncName As String, ParamArray vArgs()) As Variant
        Dim hr      As Long, vLoc() As Variant
        vLoc = vArgs
         hr = rtcCallByName(Run, WebJs, StrPtr(FuncName), VbMethod, vLoc, &H409)
        If hr < 0 Then
            MsgBox "Err:" & Err.Description
            Err.Raise hr
        End If
    End Function
    
    Public Function Func(FuncName As String, ParamArray P()) 'for max 5 Params currently
      Select Case UBound(P) + 1
        Case 0: Func = CallByName(mDoc.Script, FuncName, VbMethod)
        Case 1: Func = CallByName(mDoc.Script, FuncName, VbMethod, P(0))
        Case 2: Func = CallByName(mDoc.Script, FuncName, VbMethod, P(0), P(1))
        Case 3: Func = CallByName(mDoc.Script, FuncName, VbMethod, P(0), P(1), P(2))
        Case 4: Func = CallByName(mDoc.Script, FuncName, VbMethod, P(0), P(1), P(2), P(3))
        Case 5: Func = CallByName(mDoc.Script, FuncName, VbMethod, P(0), P(1), P(2), P(3), P(4))
      End Select
    End Function

  6. #6
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Can RC6-ActionScript only use IE Engine when parsing JS?

    if you only for js,can use v8js.dll ,or Implements IActiveScriptSite it's support js9
    for js ,can use
    1,CreateObject("htmlfile")
    2,scriptcontrol
    3,IActiveScriptSite
    4,v8js.dll
    5,miniblink.dll
    6,cef
    7,edge webview2
    8,webbrowser
    9,CreateObject("InternetExplorer.Application")

  7. #7
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Can RC6-ActionScript only use IE Engine when parsing JS?

    how to get VarPtr(vArgs)?

    like Dim pVarg As Long
    'GetMem4 ByVal StrPtr(FuncName) + 4, pVarg

    Code:
    Public Function Run2(FuncName As String, ParamArray vArgs()) As Variant
        Dim hr      As Long
        
    
         Dim pVarg   As Long
        'GetMem4 ByVal StrPtr(FuncName) + 4, pVarg
        GetMem4 ByVal VarPtr(vArgs), pVarg ????
        
        hr = Vb6CallByName(Run2, WebJs, StrPtr(FuncName), VbMethod, ByVal pVarg, &H409)
        
        If hr < 0 Then
            MsgBox "Err:" & Err.Description
            Err.Raise hr
        End If
    End Function
    Code:
    Private Function Api_CallByName( _
                     ByVal cObject As Object, _
                     ByRef sProcName As String, _
                     ByVal eCallType As VbCallType, _
                     ParamArray vArgs() As Variant) As Variant
    '如果被调用的函数,参数中的值被更改,也是会返回正确值
        Dim hr      As Long
        Dim pVarg   As Long
    
        GetMem4 ByVal VarPtr(eCallType) + 4, pVarg
    
        hr = Vb6CallByName(Api_CallByName, cObject, StrPtr(sProcName), eCallType, ByVal pVarg, &H409)
    
        If hr < 0 Then
            Err.Raise hr
        End If
    
    End Function

  8. #8
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Can RC6-ActionScript only use IE Engine when parsing JS?

    Code:
    ReDim Sz(11)
    Sz(0) = "function add(a, b) {"
    Sz(1) = "" & Chr(9) & "return a + b;"
    Sz(2) = "}"
    Sz(3) = ""
    Sz(4) = "function isExitsFunction(funcName) {"
    Sz(5) = "" & Chr(9) & "try {"
    Sz(6) = "" & Chr(9) & "" & Chr(9) & "if (typeof(eval(funcName)) == ""function"") {"
    Sz(7) = "" & Chr(9) & "" & Chr(9) & "" & Chr(9) & "return true;"
    Sz(8) = "" & Chr(9) & "" & Chr(9) & "}"
    Sz(9) = "" & Chr(9) & "} catch (e) {}"
    Sz(10) = "" & Chr(9) & "return false;"
    Sz(11) = "}"
    S = Join(Sz, " ")
    Js.AddCode S
    Code:
    Private Declare Function Vb6CallByName Lib "msvbvm60" Alias "rtcCallByName" ( _
            ByRef vRet As Variant, _
            ByVal cObj As Object, _
            ByVal sMethod As Long, _
            ByVal eCallType As VbCallType, _
            ByRef pArgs As Any, _
            ByVal lcid As Long) As Long
    Public ErrInfo As String
    Public Function Run(FuncName As String, ParamArray vArgs()) As Variant
    On Error GoTo Err
        Dim hr      As Long
        If Not WebJs.isExitsFunction(FuncName) Then Run = "Js Function Not Exit": Exit Function
        'If the js function does not exist, executing the call will cause the process to crash
        hr = Vb6CallByName(Run, WebJs, StrPtr(FuncName), VbMethod, ByVal VarPtr(FuncName) - 4, &H409)
        If hr < 0 Then
            MsgBox "Err:" & Err.Description
            Err.Raise hr
        End If
    Exit Function
    Err:
    MsgBox "ERR:" & Err.Number & "," & Err.Description
    End Function

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Re: Can RC6-ActionScript only use IE Engine when parsing JS?

    Quote Originally Posted by Schmidt View Post
    JScript(9) probably parses and recognizes any occurence of "return" as a "hard keyword"...
    though since js allows property-access also via String-Literal in square-brackets,
    one could write the whole thing also this way (to make the error go away):

    Code:
        With New_c.StringBuilder
            .AddNL "function maybeInvokeDelegate(delegate, context) {"
            .AddNL "    var method = delegate.iterator[context.method];"
            .AddNL "    if (method === undefined) {"
            .AddNL "      if (context.method === 'throw') {"
            .AddNL "        if (delegate.iterator['return']) {"
            .AddNL "        }"
            .AddNL "      }"
            .AddNL "      return ContinueSentinel;"
            .AddNL "    }"
            .AddNL "}"
    
            sSource = .ToString()
        End With
    Sorry for the late reply. Yes, this issue was fixed after I changed the return keyword. But many more problems have arisen. That said, Svelte uses a lot of new JS-syntax, and I need to make compatibility changes to all of these new JS-syntax, which is not within my competence.


    Quote Originally Posted by Schmidt View Post
    As for accessing the V8-js-engine in Chromium-based WebView2 -
    the interaction with the VB-side works only via "OutOfProcess-COM-marshaling" -
    whereas the ActiveScripting-interfaces of cActiveScript allow InProcess-interaction with the supported Interpreters.
    The problem is that cActiveScript doesn't support a lot of the new JS-syntax. That is, when I choose a popular JS-lib, I need to test whether the lib contains syntax that cActiveScript does not support.

    cActiveScript is great, but it can't keep up with JS-syntax updates.

    Quote Originally Posted by Schmidt View Post
    The "visibility-requirement" I'd not consider a larger problem...
    since in your shoes, I'd implement "most of the IDE-GUI" inside the WebView2 anyways
    (as e.g. Wayne does with the TwinBasic-IDE)... including a decent js-based Editor-Widget like e.g. Monaco.
    Yes, most people would choose a WebView-based technology solution, but I still want to use a traditional desktop software solution.
    Last edited by SearchingDataOnly; Jun 1st, 2023 at 05:45 AM.

  10. #10
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Can RC6-ActionScript use a non-IE engine when parsing JS?

    The Google chrome kernel is open source, and you can strip the V8 JS engine out of it, compile it into a DLL, or a v8js.lib static library, and then compile it into a standalone application with the VB6 source code.

    Today, I turned a 5000-line JS code file into a 5000-line array load. He suggested that the code was too much, and then I separated it into three processes to complete it. And the compilation time has changed from one second to 50 seconds.
    Last edited by xiaoyao; Jun 1st, 2023 at 06:45 AM.

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Re: Can RC6-ActionScript use a non-IE engine when parsing JS?

    Quote Originally Posted by xiaoyao View Post
    The Google chrome kernel is open source, and you can strip the V8 JS engine out of it, compile it into a DLL, or a v8js.lib static library, and then compile it into a standalone application with the VB6 source code.

    Today, I turned a 5000-line JS code file into a 5000-line array load. He suggested that the code was too much, and then I separated it into three processes to complete it. And the compilation time has changed from one second to 50 seconds.
    Thank you for the advice, but I really don't have time for that extra work. I spent too much time on JS (I read and learned more than 20 JS-Parser sources), but gained too little. I now need to concentrate on finishing my scripting language IDE

  12. #12
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Can RC6-ActionScript use a non-IE engine when parsing JS?

    Yes, you're right. Stand on the shoulders of giants.
    edge webview2 It's very powerful, so twinbasic shows it as its default UI.
    I feel that your type library viewer function is really perfect, but the serious interface is really ugly, do not be sad.

    The development of IDe will always have a focus.
    Like 100% VB6 compatible. It also provides unlimited expansion capabilities and supports assembly. Support GCC compilation optimization。
    Although you may be talking about just a scripting tool.
    I feel that vbsedit has not been updated for more than ten years.
    In fact, his code parsing, as well as many of the features inside are excellent, the only thing he lacks is a visual form designer.

    miniblink.dll (V8 7.5 VERSION,ABOUT 2019-6-1) ,The size is only 30mb,He doesn't need to spend money to buy it. It's free.
    which is much smaller than five or six hundred megabytes and 500mb edge webview.
    Used to achieve a beautiful web interface. And the V8 JS engine are perfectly adequate。

    Microsoft's js9 engine has not improved over the years(version maybe 2010 year)
    He could have imported the VB6 project to net2005, 2008 perfectly, but he gave up long ago. The function may be only 30% or even 15%.
    In the end, twinbasic managed to do just that.

    https://download.csdn.net/download/jennyvenus/10025782
    Pre-compiled dynamically-linked google v8 lib dll library for Windows
    v8.dll x64+x86 (4.5M,3.9M) BY 2014-4-8
    NEW VERSION WILL USED more disk space

    VS2019 Google v8 8.4 version (v8.DLL 20.03MB, v8.dl.lib 9.3MB) compiled Release version of dll and LIB, and test demo_v8 dll resource -CSDN library
    https://download.csdn.net/download/qq_33958297/19887037
    Last edited by xiaoyao; Jun 1st, 2023 at 10:42 AM.

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Re: Can RC6-ActionScript use a non-IE engine when parsing JS?

    Quote Originally Posted by xiaoyao View Post
    I feel that your type library viewer function is really perfect, but the serious interface is really ugly, do not be sad.
    I intentionally made my TlbViewer UI exactly mimic VB6's, so that users can feel familiar and they can use it without any documentation.

    In addition, my TlbViewer has some really amazing features that will not be visible until the TlbViewer is officially released.

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