Announcement

Collapse
No announcement yet.

"Member Get" & "Property Get"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Robert Wallace
    replied
    Have I finally hit a brick wall
    Finally knocked it down

    I regenerated the inc files as IDBIND and the final code worked OK:

    Code:
    #DIM ALL
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "win32api.inc"                        'add win32api if not already added
    #ENDIF
    #INCLUDE "IBIND_FrameAC.inc"
    #INCLUDE "IBIND_FrameACType.inc"
    '#INCLUDE "FDKTypes2.inc"
    '#INCLUDE "FrameACUDT.inc"
    
    
    GLOBAL theFrameEx AS DISPATCH
    GLOBAL myFrameEx AS DISPATCH
    GLOBAL myFrameAuthorise AS DISPATCH
    GLOBAL mySession AS DISPATCH
    GLOBAL myDocument AS DISPATCH
    
    GLOBAL tempv AS LONG
    GLOBAL vtemp AS VARIANT
    
    FUNCTION PBMAIN () AS LONG
    
    theFrameEx = NEW DISPATCH IN "FrameAC.FrameEx"
    
    myFrameAuthorise = NEW DISPATCH IN "FrameAC.FrameAuthorise"
    
    OBJECT GET theFrameEx.Session TO mySession
    
    OBJECT CALL mySession.Initialise(myFrameAuthorise) TO tempv
    IF tempv <> 1 THEN
      MSGBOX "Failed to connect to FrameMaker
    END IF
    
    OBJECT GET mySession.ActiveDoc TO myDocument
    
    OBJECT GET myDocument.Name TO vtemp
    
    MSGBOX VARIANT$(vtemp)
    
    END FUNCTION

    Leave a comment:


  • Robert Wallace
    replied
    No doubt the part of the VB code not shown must be doing something with that authorisation object somewhere before the Initialise method is called.
    Unfortunately there is nothing missing from the VB6 - I have to insert that code into every program I write.

    Have I finally hit a brick wall

    Many thanks again for trying to help

    Bob

    Leave a comment:


  • José Roca
    replied
    No doubt the part of the VB code not shown must be doing something with that authorisation object somewhere before the Initialise method is called.

    BTW remove the SET in SET oDoc = theSession.ActiveDoc. SET is not used with direct interface calls.

    Leave a comment:


  • Robert Wallace
    replied
    More help needed

    I have now expanded the code to the next step - which is one I have never encountered before - the line in red returns an error value - The problem is that code prior to this statement returns no errors but I don't know if I have created the code correctly: (all the interface methods and properties are as listed previously)
    Code:
    #DEBUG ERROR ON
    #COMPILE EXE
    #DIM ALL
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "win32api.inc"                        'add win32api if not already added
    #ENDIF
    #INCLUDE "FrameACType.inc"
    #INCLUDE "FrameAC.inc"
    #INCLUDE "FDKTypes2.inc"
    #INCLUDE "FrameACUDT.inc"
    
    GLOBAL authorisation AS IFrameAuthorise
    GLOBAL theEx AS IFrameEx
    GLOBAL theSession AS IFMSession
    
    FUNCTION PBMAIN () AS LONG
    LOCAL oDoc AS IFMDocument
    LOCAL tempv AS LONG
    LOCAL temps AS STRING
    
    theEx =  NEWCOM CLSID $CLSID_FRAMEACLib_FrameEx     '  ISNOTHING(theEx) returns valid object
    authorisation = NEWCOM CLSID $CLSID_FRAMEACLib_FrameAuthorise
    
    IF ISNOTHING(authorisation)OR ERR THEN
      MSGBOX "Bad"
    ELSE
      MSGBOX "good"    'returns here
    END IF
    
    theSession =  theEx.session
    
    IF ISNOTHING(theSession)OR ERR THEN
      MSGBOX "Bad"
    ELSE
      MSGBOX "good"    'returns here
    END IF
    
    [COLOR="Red"]tempv = theSession.Initialise(authorisation)[/COLOR]
    IF tempv <> 1 THEN
      MSGBOX "Not connected to FrameMaker"   'returns here with large number
      EXIT FUNCTION
    END IF
    
    SET oDoc = theSession.ActiveDoc
    
    temps = oDoc.Name
    
    MSGBOX temps
    
    END FUNCTION
    Last edited by Robert Wallace; 27 Jul 2009, 09:16 AM.

    Leave a comment:


  • Robert Wallace
    replied
    Many thanks for the explanation.

    Bob

    Leave a comment:


  • José Roca
    replied
    Originally posted by Robert Wallace View Post
    You have mentioned the above in my thread and the previous thread - Do you mean that I am using PB's COM Browser incorrectly

    Bob
    There are two ways of using COM with PB: Automation (OBJECT GET/LET/SET/CALL) and direct interface calls.

    The PB COM Browser generates interface declarations for direct interface call use by default. If you intend to use it with OBJECT CALL, etc., then you must instruct the browser to generate IDBIND interfaces. Click Menu-->Tools-->Options and check the "Generate Dispatch Interfaces only" option.

    Leave a comment:


  • Robert Wallace
    replied
    To José

    If you generate interface declarations for direct interface call use, then don't use OBJECT GET, that is for IDBIND interfaces.
    You have mentioned the above in my thread and the previous thread - Do you mean that I am using PB's COM Browser incorrectly

    Bob

    Leave a comment:


  • Jeff Blakeney
    replied
    Originally posted by Scott Slater View Post
    Don't forget the Type identifier for the Property.
    Whoops. Thanks for catching that.

    Leave a comment:


  • José Roca
    replied
    If you generate interface declarations for direct interface call use, then don't use OBJECT GET, that is for IDBIND interfaces.

    Instead of:

    Code:
    OBJECT GET theEx.session TO theSession
    use:

    Code:
    theSession = theEx.session

    Leave a comment:


  • Robert Wallace
    replied
    Jeff - many thanks for explaining the difference between "Method" and "Property".

    I should have presented code

    I am trying to convert a VB6 program into PB (I have successfully programmed several COM interfaces but this is in a different league entirely)

    The VB6 code :
    Code:
    Option Explicit
    Public authorisation As New FrameAuthorise
    Public theEx As New FrameEx
    Public theSession As FMSession
    
    Private Sub TakeControl_Click()
    Dim oDoc As FMDocument
    
     Set theSession = theEx.Session
     If Not theSession.Initialise(authorisation) = 1 Then
     MsgBox "Failed to connect with FrameMaker!"
     Exit Sub
     End If
    
     Set oDoc = theSession.ActiveDoc
    My Translation (so far):
    Code:
    #DEBUG ERROR ON
    #COMPILE EXE
    #DIM ALL
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "win32api.inc"                        'add win32api if not already added
    #ENDIF
    #INCLUDE "FrameACType.inc"
    #INCLUDE "FrameAC.inc"
    #INCLUDE "FDKTypes2.inc"
    #INCLUDE "FrameACUDT.inc"
    
    GLOBAL authorisation AS IFrameAuthorise
    GLOBAL theEx AS IFrameEx
    GLOBAL theSession AS IFMSession
    
    FUNCTION PBMAIN () AS LONG
    LOCAL oDoc AS IFMDocument
    
    
    theEx =  NEWCOM CLSID $CLSID_FRAMEACLib_FrameEx     '  ISNOTHING(theEx) returns valid object
    
    OBJECT GET theEx.session TO theSession
    
    END FUNCTION
    I get the following error:
    Code:
    PowerBASIC for Windows
    PB/Win  Version 9.01
    Copyright (c) 1996-2009 PowerBasic Inc.
    Venice, Florida USA
    All Rights Reserved
    
    Error 533 in C:\D_Drive\PBDLL90\Projects\FRAMEA~1\MekonTest.bas(22:012):  Dispatch Object variable expected
    Line 22: OBJECT GET theEx.session TO theSession
    ==============================
    Compile failed at 09:28:32 on 24/07/2009
    How do I code the two items in RED in the extracts from the "inc" files generated by PB?
    Code:
    ' Interface Indentifiers
    $IID_FRAMEACLib_IFrameEx = GUID$("{E6E0DD00-A895-11D3-91B3-0050BAAE27FB}")
    $IID_FRAMEACLib_IFrameAuthorise = GUID$("{E6E0DD02-A895-11D3-91B3-0050BAAE27FB}")
    $IID_FRAMEACLib_IFrameAuthorise2 = GUID$("{E5477EB0-AD66-11D3-91B5-0050BAAE27FB}")
    
    ' Interface Name  : IFrameEx
    ' Description     : IFrameEx Interface
    ' Class Name      : FrameEx
    ' ClassID         : $CLSID_FRAMEACLib_FrameEx
    ' ProgID          : $PROGID_FRAMEACLib_FrameEx
    ' Version ProgID  : $PROGID_FRAMEACLib_FrameEx1
    Interface IFrameEx $IID_FRAMEACLib_IFrameEx
        Inherit IDispatch
    
        Method Initialise <1> (ByRef pIFDK As IDispatch, ByRef cmdFirst As Long)
        Method Destroy <2> ()
        Property Get Connected <3> () As Long
        Property Get FDK <4> () As IDispatch
        [COLOR="Red"]Property Get Session <5> () As IDispatch[/COLOR]
    End Interface
    Code:
    ' Interface Name  : IFMSession
    ' Class Name      : FMSession
    ' ClassID         : $CLSID_FACLib_FMSession
    Interface IFMSession $IID_FACLib_IFMSession
        Inherit IDispatch
    
        Property Get Id <1> () As Long
        Property Set Id <1> (ByVal Rhs As Long)
        Property Get docId <2> () As Long
        Property Set docId <2> (ByVal Rhs As Long)
        Property Get UserString <3> () As String
        Property Set UserString <3> (ByVal Rhs As String)
        Property Get ObjectType <4> () As Long
        Method Delete <5> () As Long
        Method GetText <6> (Byval flags As Long, Byval Flags2 As Long) As Variant
        Method ObjectValid <7> () As Long
        Method GetPropVals <8> () As Variant
        Method SetPropVals <9> (Byval PB_Properties As Variant) As Long
        Property Get ActiveBook <10> () As IFMBook
        Property Set ActiveBook <10> (ByVal pVal As IFMBook)
        [COLOR="red"]Property Get ActiveDoc <11> () As IFMDocument[/COLOR]
        ---
        [COLOR="red"]Method Initialise <95> (Byval AuthObject As IDispatch) As Long[/COLOR]
        ---

    Leave a comment:


  • Scott Slater
    replied
    Originally posted by Jeff Blakeney View Post
    Code:
    CLASS MyClass
     ...
            PROPERTY GET CustomerNum [COLOR="Red"]As VarType[/COLOR]
                PROPERTY = lCustomerNum
            END PROPERTY
            PROPERTY SET CustomerNum(lValue[COLOR="Red"] As VarType[/COLOR])
                lCustomerNum = lValue
            END PROPERTY
     ...
    Don't forget the Type identifier for the Property.

    Leave a comment:


  • Jeff Blakeney
    replied
    I'm no expert at PB objects but I'm not sure what you mean here.

    PROPERTY is used when creating an object to define a special method that either GETs or SETs a value. This is a block statement and contains executable code for doing doing something with the passed value (SET) or returning a value (GET). Here is a sample of creating an object with a single property:

    Code:
    CLASS MyClass
        INSTANCE lCustomerNum AS LONG
    
        INTERFACE MyInterface
            INHERIT IUNKNOWN
    
            PROPERTY GET CustomerNum
                PROPERTY = lCustomerNum
            END PROPERTY
            PROPERTY SET CustomerNum(lValue)
                lCustomerNum = lValue
            END PROPERTY
    
        END INTERFACE
    END CLASS
    MEMBER is used when declaring the methods and properties of a dispatch interface. It tells the compiler whether the member is a method (CALL) or property (GET, SET, LET) specifies its name and any parameters it expects and the return type if any. Here is the declaration of an object for the object above.

    Code:
    INTERFACE IDBIND MyInterface
        MEMBER GET CustomerNum AS LONG
        MEMBER SET CustomerNum(IN lValue AS LONG)
    END INTERFACE
    I'm pretty sure you only need to declare the MEMBERs for COM objects and not for objects that you include as source code.

    Leave a comment:


  • Robert Wallace
    started a topic "Member Get" & "Property Get"

    "Member Get" & "Property Get"

    I know how to program "Member Get" but how do I program "Property Get"
    in a PB generated inc file?

    Bob
Working...
X