FormerMember

Object Reference Pointers

Posted By FormerMember

Within the ProvideX environment Sage 100 references their objects by an ID value starting at 100001 for SY_Session. When scripting is used, does 100 create an OLE reference (iDispatch pointer) to the object and pass that to WScript Host?  If so what is the variable name in ProvideX for the iDispatch pointer to the object?

  • FormerMember
    FormerMember

    Anyone?

    Should I assume that 100 is only passing state variables to the Script and it's the language or hosting environment creating its own set of COM  objects based on iDispatch pointers?

    Is Sage 100 BO just a custom object (OOP) implementation and the OLE layer is provided by PVXCOM.DLL? ProvideX native doesn't communicate with its objects internally via iDispatch and uses its internal ID references.

    Let me simplify my request. When are iDispatch pointers created when using customizer VBScript based scripts?

  • FormerMember
    FormerMember in reply to FormerMember

    Good advice from @Kevin M on where to run scripts.

    Server: access to business objects

    Client: access to user interface / workstation

  • FormerMember
    FormerMember in reply to FormerMember

    This is encouraging but doesn't return an iDispatch pointer but the internal ProvideX object reference ID.

    obus = COM::CBN(osession, "nGetObject", :CALL, "AR_Customer_bus")
    PRINT obus, "\n" 

    C:\ScriptBasic\examples>sbc showcust.sb
    100063

    C:\ScriptBasic\examples>

    This is a list of the object handles from an OLE interface standpoint.

    C:\ScriptBasic\examples>sbc showcust.sb
    oscript: 8518836
    osession: 8517324
    oui: 8518404
    obus: 100063

    C:\ScriptBasic\examples>

    The obus object handle was returned from the GetObject method call.

    It sure would be nice to get a clear explanation of when OLE and the iDispatch interface comes into play. 

  • FormerMember
    FormerMember in reply to FormerMember

    I tried to get the object handle from VBScript but no luck. Getting the TypeName of the object shows IPvxDispatch.

    I'm beginning to wonder if under the covers VBScript is using ProvideX's internal object reference IDs and ScriptBasic is showing its iDispatch pointer reference.

  • FormerMember
    FormerMember in reply to FormerMember

    I used the ScriptBasic DI (Display Typelib Interface) function on the osession variable ScriptBasic created.

    Interface: IPvxDispatch
    CLSID: {60503ABA-2D27-11D6-B249-00C04F50D575}
    Version: 1.0
    Get Instance() As String
    Get CmdHandle() As Long
    Get ScriptObject() As Object
    Sub DropObject()
    Sub FinalDropObject()
    

    Here is the results of getting the object's properties.

    C:\ScriptBasic\examples>sbc showcust.sb
    ScriptBasic oscript: 10353684
    osession instance: {7E027EA0-D44F-4642-8B9C-2C1FE34B9C4D}
    osession CmdHandle: 100001
    osession ScriptObject: 10353684
    osession ScriptBasic: 10353828

    C:\ScriptBasic\examples>

    If I can pass the ScriptObject value from 100 to ScriptBasic on the DLL call of the NOMADS event, I might be able to use it without creating an OLE object in ScriptBasic.

  • FormerMember
    FormerMember in reply to FormerMember

    Does anyone know if one is able to access COM/OLE automation objects from within a ProvideX based script?

  • FormerMember
    FormerMember in reply to FormerMember

    I'm still trying to untangle when or if ProvideX object IDs become iDispatch pointers for OLE access, My initial thought was oScript was the parent object and all other objects were children of that object. WRONG

    Quote:

    There is a separate script object for each business object for which scripts have been tied to events usin User Defined Scripts. For example, SO_InvoiceDetail_bus has a script object associated with it, and SO_Invoice_bus (header object) has its own script object. Also, scripts run from the User Interface using a Customizer BT_Link script button have a separate script object.

    I would like to pass to ScriptBasic 100 object iDispatch pointers that instantiated  by the Customer Maintenance for example. The mystery for me has been unless I CreateObject in ScriptBasic for a 100 object, an iDispatch pointer isn't created. A value of 100001 for SY_Session doesn't do me any good as a COM/OLE object reference to it.

    It would be great if someone from the 100 development team could chime in and share with us the 100  iDispatch object story.

    I have not been able to to create or access any 100 objects from within a script using ProvideX object ID references.I don't think Wscipt is running in the same process as the ProvideX instance that created it. So much for passing pointers as far as I can see, It would be great to see what a 'compiled' script looks like.

  • FormerMember
    FormerMember in reply to FormerMember

    I'm making some progress. ProvideX instantiates the WSH script engine as an OLE object.  I'm still working on how ProvideX translates its object IDs in their current state to WSH.iDispatch handles.Once I figure that out I can create DLL calls to ScriptBasic on NOMADS events bypassing traditional scripting.

    I'm learning a lot talking to myself. Joy

    IMPORT COM.sbi
    
    oscript = COM::CREATE(:SET, "MSScriptControl.ScriptControl")
    COM::DI(oscript)
    
    COM::RELEASE oscript
    

    This is the typelib for WSH.

    Interface: IScriptControl
    ProgID: MSScriptControl.ScriptControl.1
    CLSID: {0E59F1D5-1FBE-11D0-8FF2-00A0D10038BC}
    Get Language(pbstrLanguage As Object) As Hresult
    Let Language(pbstrLanguage As String) As Hresult
    Get Timeout(plMilleseconds As Object) As Hresult
    Let Timeout(plMilleseconds As Long) As Hresult
    Get AllowUI(pfAllowUI As Object) As Hresult
    Let AllowUI(pfAllowUI As Boolean) As Hresult
    Get UseSafeSubset(pfUseSafeSubset As Object) As Hresult
    Let UseSafeSubset(pfUseSafeSubset As Boolean) As Hresult
    Get CodeObject(ppdispObject As Object) As Hresult
    Get Procedures(ppdispProcedures As Object) As Hresult
    Function AddObject(Name As String, Object As Object, [AddMembers As Boolean = False]) As Hresult
    Function Reset() As Hresult
    Function AddCode(Code As String) As Hresult
    Function Eval(Expression As String, pvarResult As Object) As Hresult
    Function ExecuteStatement(Statement As String) As Hresult
    Function Run(ProcedureName As String, Parameters As Object, pvarResult As Object) As Hresult
    

  • in reply to FormerMember

    See this link for creating COM/OLE objects when using ProvideX.

    DEF OBJECT Define Windows Object (pvxplus.com)

  • FormerMember
    FormerMember in reply to David Speck

    The problem isn't ProvideX creating an OLE iDispatch pointer with DEF OBJECT, it's converting an existing 100 object that has its properties already defined to an iDispatch version of it so I can pass that pointer to ScriptBasic in a DLL call. ProvideX and ScriptBasic are running in the same Windows process so passing pointers works great.