dcsimg
Results 1 to 2 of 2

Thread: cActiveScript (vbRichClient5) vs ScriptControl (msscript.ocx)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2017
    Posts
    19

    cActiveScript (vbRichClient5) vs ScriptControl (msscript.ocx)

    Hi all

    I tried to search in google and in these forums a little more information about cActiveScript class in vbRichClient5. I don't even know if I am allowed to ask about this, if it is not the case I apologize for that

    I am developing an application that lets the user write some code in vbScript, JScript or python and accessing the application objects using msscript.ocx

    I am using now Olaf's vbRichClient5 and I have seen this cActiveScript class. I just wanted to know if any of you have used it or have a little more info about its advantages vs the usual msscript.ocx

    I am missing little features as the last error Object (with more info then the LastErrString) or the Procedures collection

    Thank you!

  2. #2
    PowerPoster
    Join Date
    Jun 2013
    Posts
    3,804

    Re: cActiveScript (vbRichClient5) vs ScriptControl (msscript.ocx)

    Quote Originally Posted by nicopeis View Post
    I don't even know if I am allowed to ask about this, if it is not the case I apologize for that
    Don't let the opinions of a few Forum-Users intimidate you...

    There's tons of questions about e.g. Crystal-Reports in this Forum (which is PayWare) -
    whereas vbRichClient5 is a free obtainable COM-lib, and the only unicode-aware Class-Framework we have in the Community,
    which is "as complete" and comes with such stable and well-tested Class-interfaces (so that code-examples will work for everyone in the same way).

    Quote Originally Posted by nicopeis View Post
    I am using now Olaf's vbRichClient5 and I have seen this cActiveScript class.
    I just wanted to know if any of you have used it or have a little more info about its advantages vs the usual msscript.ocx
    Well, it surely does offer a few advantages over the msscript.ocx as e.g.:
    - full coverage of all VB6-Enums and Constants within VBScript-Code
    - full coverage of all vbRichClient5 Enums and Constants within VBScript-Code
    - global "visibility" of the RC5 Main-entry-Objects (New_c and Cairo, from which you can instantiate all other RC5-Classes) (that's available also in JScript for example)
    - a Set of AddOn-Functions for more VB6-compatibility (as e.g. IIf, VarPtr, StrPtr, ObjPtr, Val, Str, StrConv, Format, Environ, Beep, DoEvents_)
    - Event-Support inside VBScript- defined Classes
    - Event-Support inside normal VBScript-Code
    - Ability to call Win32-API-functions from within ScriptCode (due to New_c being available inside the Script)
    - Support for the (quite a lot faster) JScript9-engine (on machines which have an IE-version > 9 installed)

    I wrote it mainly, to be able to implement DB-stored "scripted RC5-Forms" (which change often on the customer-side, to be able to change them without recompiling the App-Binaries)

    Quote Originally Posted by nicopeis View Post
    I am missing little features as the last error Object (with more info then the LastErrString) or the Procedures collection
    A few more Error-Infos can be obtained, when you declare the cActiveScript-Variable WithEvents
    (the Error-Event will hand out also the Line- and Col-Numbers then).

    Though the "Modules" and "Procedures"-Collections you will have to implement yourself (which shouldn't be a larger problem IMO).

    Below comes an (only *.bas-Module Sub Main() based) example,
    how to use such Scripts in conjunction with the "globally visible" New_c and Cairo-EntryPoints (which one already knows from "normal RC5+VB6-examples"):

    Code:
    Option Explicit
    
    Sub Main()
      Dim SC As cActiveScript, SB As cStringBuilder
      Set SC = New_c.ActiveScript
      Set SB = New_c.StringBuilder
      
      'first we add Code for a VBScript-Class (a simple Cairo-Widget)
        SB.AppendNL "Class cwMyWidget"
        SB.AppendNL "  Dim W"
      
        SB.AppendNL "  Sub Class_Initialize()"
        SB.AppendNL "     Set W = Cairo.WidgetBase"
        SB.AppendNL "         W.Moveable = True"
        SB.AppendNL "     AddEventSinkOn Me, 'W_Paint', 6" '<- the ParamCount of the Event-Handler needs to be passed
        SB.AppendNL "  End Sub"
        
        SB.AppendNL "  Property Get Widget():  Set Widget = W:          End Property"
        SB.AppendNL "  Property Get Widgets(): Set Widgets = W.Widgets: End Property"
      
        SB.AppendNL "  Sub W_Paint(ByVal CC, ByVal x, ByVal y, ByVal dx, ByVal dy, ByVal UserObj)"
        SB.AppendNL "      CC.Paint 1, Cairo.CreateSolidPatternLng(vbMagenta, 0.3)"
        SB.AppendNL "      S = 'Hello World' & vbCrLf & 'from ' & W.Key & vbCrLf & '(move me around)'"
        SB.AppendNL "      CC.DrawText 0, 0, dx, dy, CStr(S), False, vbCenter, 4, True"
        SB.AppendNL "  End Sub"
        SB.AppendNL "End Class"
     
      'finally we add the Main-Code (using a Cairo-Form, two Widget-Class-Instances from the code above, and a RC5-cTimer)
        SB.AppendNL "Set Form = Cairo.WidgetForms.Create(vbSizable, 'Form-Caption', True, 480, 320)"
        SB.AppendNL "    Form.Widgets.Add New cwMyWidget, 'MyWidget1', 10, 10, 150, 150"
        SB.AppendNL "    Form.Widgets.Add New cwMyWidget, 'MyWidget2', 60, 60, 150, 150"
        SB.AppendNL "Set Timer1 = New_c.Timer(600, True): AddEventSupportFor 'Timer1'"
      
        SB.AppendNL "Sub Timer1_Timer()"
        SB.AppendNL "    Form.Caption= 'Form-Caption: ' & Now"
        SB.AppendNL "End Sub"
        
        SB.AppendNL "Form.Show vbModal"
          
      'the main-code (since it is not wrapped in a Sub-Routine) is now immediately executed "On Add"
      SC.AddCode Replace(SB.ToString, "'", """") '<- replace the single-quotes we've used in above code-defs with the needed double-quotes
      
      'we reach this point only, after the (modal) CairoForm we created in the Script above was closed...
      Set SB = Nothing
      Set SC = Nothing
      New_c.CleanupRichClientDll
    End Sub
    The above ScriptCode produces the following:



    HTH

    Olaf

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width