Results 1 to 6 of 6

Thread: Script BASIC IDE/Debugger and COM / VB6 extention module

  1. #1

    Thread Starter
    Lively Member ScriptBASIC's Avatar
    Join Date
    Oct 2014
    Location
    Anacortes, WA
    Posts
    75

    Script BASIC IDE/Debugger and COM / VB6 extention module

    The Script BASIC IDE/Debugger is a VB6 (Std-Exe) project with Script BASIC embedded. (as a editor / runtime and as a preprocessor for the debugger)

    Bitbucket Project Site & Repository
    Script BASIC Forum
    Script BASIC Wiki

    Code:
    This project aims to create a VB6 usable ScriptBasic Engine.
    along with a an integrated IDE + debugger.
    
    http://en.wikipedia.org/wiki/ScriptBasic
    
    Features include:
    
     VB6 access class to ScriptBasic Engine 
       - AddObject
       - AddCode
       ? Eval
    
     IDE as VB6 ActiveX control
       - intellisense
       - syntax highlighting
       - integrated debugger
          - breakpoints
          - single step
          - step over
          - step out
          - variable inspection 
          - call stack
          - variable modification
          - run to line
     
    Status:
       - standalone debugger and vb usable script engine is complete.
          switching over to dll/ocx control will be completed next time I 
          need this functionality embedded in another app. (hard part done)
    
    Notes:
    
      - auto complete/intellisense has several scopes. hit ctrl+space to trigger.
        if there is a partial identifer already typed, with only one match, the
        string will be auto completed. If there are multiple matches, then the 
        filtered results will be show in intellisense list. If no matches are found
        then entire list will be shown. 
    
        The following scopes are supported:
    
          - import statements - lists *.bas in specified /include directory
          - external module functions - parses the *.bas headers to build func list.
          - built in script basic functions 
          - is not currently aware of script variable names
     
       - for module functions (ex curl::) to show up, the matching import must exist
          (include file name, must match embedded module name)
    
       - debugger variable inspection / modification - When debugging a list view
         of variable names, scopes, and values is kept. You can edit values by right
         clicking its list entry. Array values can be viewed by double clicking on 
         its variable name to bring up the array viewer form. 
    
         You can also display a variable value, by hovering the mouse over it in
         the IDE window. A call tip will popup showing its value. Click on the call tip
         to being up the edit value form. Longs and string values are supported. You can
         also prefix a string with 0x for hex numbers.
    
       - parse errors will show up in their own listview. Each error will get its own entry.
         where possible line numbers, files, and error descriptions are provided. Clicking 
         on the entry will jump to that line in the IDE (if one was given by SB engine)
    
       - changes to scripts are automatically saved each time they are executed.
    
       - special hot keys:
    
                  ctrl-f - find/replace
                  ctrl-g - goto line
                  ctrl-z - undo
                  ctrl-y - redo
    
                  F2     - set breakpoint
                  F5     - go
                  F7     - single step
                  F9     - step out
                  F8     - step over
    Last edited by ScriptBASIC; Oct 30th, 2014 at 12:06 AM.

  2. #2

    Thread Starter
    Lively Member ScriptBASIC's Avatar
    Join Date
    Oct 2014
    Location
    Anacortes, WA
    Posts
    75

    Re: Script BASIC IDE/Debugger and COM / VB6 extention module

    Olaf,

    Thank you very much for the help and advice. The following Script BASIC COM extension module code interfaces with VB6 ActiveX DLL forms.

    Code:
    import com.inc
    obj = CreateObject("VB6.Sample") 
    
    'Sample function prototypes
    '	longTest(v As Long)
    '	intTest(v As Integer)
    '	ByteTest(v As Byte)
    '	GetString(prompt As String, title, def) As String
    '	ShowUI() As Long
    
    if obj = 0 then 
    	print "CreateObject failed!\n"
    else
    
        print "TypeName obj = ", TypeName(obj), "\n"
    
        CallByName(obj, "longTest", VbMethod, 20000)
        CallByName(obj, "intTest", VbMethod, 1000)
        CallByName(obj, "byteTest", VbMethod, 255)
        
        'this one fails silently because its invalid value for byte type..
        CallByName(obj, "byteTest", VbMethod, 256) 
    
        retVal = CallByName(obj, "GetString", VbMethod, "Enter some Text:", "my title", "default value!")
        print "GetString returned: ", retVal, "\n"
        
        'do NOT release objects you dont own..
        objForm = CallByName(obj, "LaunchUI")
        print "objForm = ", objForm, "\n"
        
        for i=0 to 10
            CallByName(objForm, "AddItem", VbMethod, "Hello from script basic! " & i)
        next
        
        print "Waiting until user closes form to proceede..\n"
        CallByName(obj, "BlockUntilFormCloses")
       
        sDate = CallByName(obj, "SelectDate")
        if len(sDate) = 0 then 
        	print "User pressed cancel for date selection\n"
        else
        	print "Date: ", sDate, "\n"
        end if 
        
        ReleaseObject(obj)
        print "anndddd were done!\n"
        
    end if






    Last edited by ScriptBASIC; Oct 29th, 2014 at 11:40 PM.

  3. #3

    Thread Starter
    Lively Member ScriptBASIC's Avatar
    Join Date
    Oct 2014
    Location
    Anacortes, WA
    Posts
    75

    Re: Script BASIC IDE/Debugger and COM / VB6 extention module

    This is an example of using the Script BASIC COM interface with Excel 2010.



    Code:
    IMPORT com.inc
    
    CONST XlHAlign_xlHAlignCenter = -4108
    CONST XlBorderWeight_xlMedium = -4138
    
    ' create Excel worksheet
    filename = "c:\\SB22\\sbcom\\excel\\warehouse.xls"
    oExcelApp = CreateObject("Excel.Application")
    oWorkBook = CallByName(oExcelApp, "Workbooks", vbGet)
    oExcelWorkbook = CallByName(oWorkBook, "Add")
    oExcelSheet = CallByName(oExcelWorkbook, "Worksheets", vbGet, 1)
    
    ' change interior color of cells "B1:B5" rose (solid)
    oRange =  CallByName(oExcelSheet, "Range", vbGet, "B1:B5")
    oInterior = CallByName(oRange, "Interior", vbGet)
    CallByName oInterior, "ColorIndex", vbLet, 38
    CallByName oInterior, "Pattern", vbLet, "xlSolid"
    ReleaseObject oRange
    ReleaseObject oInterior
    
    ' put data in cell G3
    oRange =  CallByName(oExcelSheet, "Range", vbGet, "G3")
    CallByName oRange, "Value", vbLet, 123
    
    ' center the data in cell G3
    CallByName oRange, "HorizontalAlignment", vbLet, XlHAlign_xlHAlignCenter
    
    ' Set the font attribute to BOLD in G3
    oFont = CallByName(oRange, "Font", vbGet)
    CallByName oFont, "Bold", vbLet, TRUE
    
    ' Change font in G3 to purple
    CallByName oFont, "Color", vbLet, 0xFF00FF
    
    ' Change font in G3 to 20 pt Courier New
    CallByName oFont, "Name", vbLet, "Courier New"
    CallByName oFont, "Size", vbLet, 20
    
    ' Place BOLD border around cell G3
    CallByName oRange, "BorderAround", vbMethod, 1, XlBorderWeight_xlMedium, 3
    ReleaseObject oFont
    ReleaseObject oRange
    
    ' Add long string to cell E2, short number to C1
    oRange = CallByName(oExcelSheet, "Range", vbGet, "C1")
    CallByName oRange, "Value", vbLet, 2
    ReleaseObject oRange
    oRange = CallByName(oExcelSheet, "Range", vbGet, "E2")
    CallByName oRange, "Value", vbLet, "Testing long string"
    ReleaseObject oRange
    
    ' Save worksheet and release Excel worksheet memory
    CallByName oExcelWorkbook, "SaveAs", vbMethod, filename
    CallByName oExcelWorkbook, "Close"
    CallByName oExcelApp, "Quit"
    ReleaseObject oExcelSheet
    ReleaseObject oExcelWorkbook
    ReleaseObject oWorkBook
    ReleaseObject oExcelApp

  4. #4

    Thread Starter
    Lively Member ScriptBASIC's Avatar
    Join Date
    Oct 2014
    Location
    Anacortes, WA
    Posts
    75

    Re: Script BASIC IDE/Debugger and COM / VB6 extention module

    My goal is to get the VBCCR11.OCX common controls replacement library working with ActiveX DLL/EXE based forms. The library is working great with the Script BASIC IDE/Debugger on XP, Win7 and Win10 preview. I feel there is still life in using VB6 as an IDE / COM component builder to be used with other COM aware languages.

    FYI The author of the Script BASIC COM project is unable to continue on with the project due to medical issues. What Dave Zimmer (dzzie) has contributed is usable and a foundation for what might come next.

    Quote Originally Posted by David Zimmer
    ScriptBasic Debugger

    Script Basic is robust, GPL, cross platform
    scripting engine using the Basic language written by
    Peter Verhas.

    Wikipedia has a very good overview of the engine,
    and capabilities:

    en.wikipedia.org/wiki/ScriptBasic

    I was looking for a basic scripting engine that I could
    embed in my VB6 apps in place of the MS script control.
    I also wanted one that had debugger support so that users
    had debug functionality when scripting my apps.

    There were four stages to see if I could use ScriptBasic for
    this use

    1) create a vb6 usable version of the script basic engine - complete
    2) write a debugger GUI and integrate it with the engine - complete
    3) write a COM extension to let scripts access VB6 objects - complete
    4) wrap all the components together into an ocx control - not started

    All of the hard stuff is complete, and came out really well. The
    debugger supports single step, step over, breakpoints, run time variable
    inspection, call stack, syntax highlighting, and all the GUI features
    you would expect from a modern debugger.

    You can see a demo of it in action here:

    ScriptBasic Debugger Demo

    Due to tendonitius issues in my arms, I am no longer working on it, but
    it is a significant codebase that I still wanted to share with others in
    case you have a need for a similar capabilities in your apps.

    The standalone debugger, script engine and COM extension are all complete
    and quite useful on their own. Being able to embed it all would be the ultimate
    feature, but it is really a complete app in what it is already.

    I am posting this so people are aware of the project, and maybe pass the torch
    on to other developers who would have the same vision for how awesome the final
    goal could be.

    You can download all of the source and precompiled binaries from the git hub
    repo here:

    Script BASIC Control


    ScriptBasic also has a user forum here:

    Script BASIC Forum
    Last edited by ScriptBASIC; Oct 30th, 2014 at 09:54 PM.

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

    Re: Script BASIC IDE/Debugger and COM / VB6 extention module

    Quote Originally Posted by ScriptBASIC View Post
    Olaf,

    Thank you very much for the help and advice. The following Script BASIC COM extension module code interfaces with VB6 ActiveX DLL forms.

    Code:
    import com.inc
    obj = CreateObject("VB6.Sample") 
    
    'Sample function prototypes
    '	longTest(v As Long)
    '	intTest(v As Integer)
    '	ByteTest(v As Byte)
    '	GetString(prompt As String, title, def) As String
    '	ShowUI() As Long
    
    if obj = 0 then 
    	print "CreateObject failed!\n"
    else
    
        print "TypeName obj = ", TypeName(obj), "\n"
    
        CallByName(obj, "longTest", VbMethod, 20000)
        CallByName(obj, "intTest", VbMethod, 1000)
        CallByName(obj, "byteTest", VbMethod, 255)
        
        'this one fails silently because its invalid value for byte type..
        CallByName(obj, "byteTest", VbMethod, 256) 
    
        retVal = CallByName(obj, "GetString", VbMethod, "Enter some Text:", "my title", "default value!")
        print "GetString returned: ", retVal, "\n"
        
        'do NOT release objects you dont own..
        objForm = CallByName(obj, "LaunchUI")
        print "objForm = ", objForm, "\n"
        
        for i=0 to 10
            CallByName(objForm, "AddItem", VbMethod, "Hello from script basic! " & i)
        next
        
        print "Waiting until user closes form to proceede..\n"
        CallByName(obj, "BlockUntilFormCloses")
       
        sDate = CallByName(obj, "SelectDate")
        if len(sDate) = 0 then 
        	print "User pressed cancel for date selection\n"
        else
        	print "Date: ", sDate, "\n"
        end if 
        
        ReleaseObject(obj)
        print "anndddd were done!\n"
        
    end if
    I'd suggest that you familiarize yourself a bit more with VB6, before you attempt
    a serious Binding...

    Not sure if you are aware of - that you can do roundtrip-debugging over the COM-
    Class of your Dll ("VB6.Sample" that is), when you include that Project into a group
    (just make sure you're setting 'Project-Compatibility' in the Dll-Poject Settings-Dialogue
    before doing that).

    Also the error you get (cannot open non-modal Form) from the Dll-Project can easily
    circumvented, when you just show the Dll-Hosted Form in question modally.

    Also not sure, if you know the Term "modal Form" already (or the Enum-Value vbModal) -
    and what the implications are, when a Form is shown modally.

    In short - Forms shown that way will enter their own MessageLoop - and will not return
    until they are closed...

    That seems to be exactly what you want to accomplish - because when I look at your
    ScriptBasic-Lines:
    Code:
        print "Waiting until user closes form to proceede..\n"
        CallByName(obj, "BlockUntilFormCloses")
    And the matching code in your Dll-Class:
    Code:
    'this allows the form to stay open and pauses script basic execution until
    'the form is closed
    Public Sub BlockUntilFormCloses()
        While Not f Is Nothing
            DoEvents
            Sleep 20
        Wend
    End Sub
    Then this is basically the same message-pumping, a modally shown VB6-Form will do for
    you automatically, when you call the Form.Show method with the (optional) vbModal-Flag...

    So showing the Dll-internal VB6-Form modally will not only straighten out your Code
    (because your BlockUntilFormCloses-mechanism will become superfluous) - it will also
    get rid of the Error-Message you got - and makes something like the ShowWindow-API-hack
    completely unnecessary.

    ---------------------------------------------------------

    In general I'm not at all clear, what you really want to accomplish in the end.

    If your goal is, to only offer better COM-interoperability, then I'd suggest to introduce
    at least "dotted syntax for easier method-calling" into the language - similar to what
    VBScript allows - should not be all that hard to implement or replace such notations
    into proper (hidden) "CallByName"-calls (especially since you currently make no use of
    "The Dot" in the language IMO).

    Though if the goal of the exercise is, to just write a Form-Designer for IUP-based GUIs,
    then I can't really see, why you would need COM-interaction (with Dll-hosted Forms) at all.

    If you want to use VB6 only as a Tool to write your "IDE" a little bit more conveniently - fine -
    but since both environments can access e.g. __stdcall Dlls, it would be fairly easy to use
    one of them as the "messaging-interface" between both worlds (or a mix of the rudimentary
    COM-calling mechanism as it is currently + callbacks from VB6 per __stdcall-APIs would be
    entirely sufficient too). You don't really need an ActiveX-Dll-Project which handles VB-Forms,
    you can define and use those VB-Forms directly in a normal VB6-Exe-project - and manage
    the communication with your Scripting-Engine there "in place"... (e.g. by passing the Forms
    Object-Pointers into the Scripting-Context per __stdcall-API).

    As for the location of the vbRichClient5-framework - it's downloadable at vbRichClient.com.

    Olaf

  6. #6

    Thread Starter
    Lively Member ScriptBASIC's Avatar
    Join Date
    Oct 2014
    Location
    Anacortes, WA
    Posts
    75

    Re: Script BASIC IDE/Debugger and COM / VB6 extention module

    I'd suggest that you familiarize yourself a bit more with VB6, before you attempt a serious Binding...
    I picked up Dave's project due to health issues. I'm looking for a VB expert like Dave to help mentor this along.

    All I'm trying to do is get ActiveX DLL forms to theme and hopefully use the updated common controls being offered. The SB COM interface already supports the forms calling back to Script BASIC script functions for processing. I can't see anyone being interested in forms that look & function like Windows 2000. I couldn't be happier with the work Krool has done for Std-Exe based forms.

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