No announcement yet.

Why is Object Let Required

  • Filter
  • Time
  • Show
Clear All
new posts

    Why is Object Let Required

    I wonder why an object property assignment must be preceded by "Object Let", such as this:

    v = %True
    Object Let oOCX.Connected = v
    Help says it must, of course, but since the variable "oOCX" must be defined as an object elsewhere in code, couldn't the compiler fill in the "Object Let"? Let is optional in other types of variable assignments, so why not with Object variables

    Perhaps there Is there some kind of compile-time reason that oOCX cannot be determined to be an Object?

    Because it's not a simple assignment?
    "There are five general forms of the OBJECT statement which are used to communicate through a Dispatch interface to an object."


      Howdy, Stuart!

      I don't think that's sufficient reason. At least 4 of the forms seem easy enough to inspect to identify the underlying form. I'm not sure how the RaiseEvent should be written for easy visual interpretation.

      oOCX.value = 5                               'Get ... return a property
      oOCX.value = oOCX.anothervalue  'Get ... return a property
      v = OCX.value                                 'Let ... set a property
      oOCX.myMethod(v)                        'Call a function
      I can appreciate that the required format is easier to visually interpret, but still not sure of the technical necessity.


        It is what it is:

        "through a Dispatch interface"

        "When you use DISPATCH, the compiler actually passes the name of the METHOD you wish to execute as a text string."
        "You should note this important fact: Since a PROPERTY is a form of METHOD"

        "To call a Method through the DISPATCH interface, you will use the OBJECT statement. This differentiates it from direct access, so PowerBASIC can handle your request in the appropriate manner.
        There are five general forms of the OBJECT statement:"

        "Dispatch OBJECT Method calls may be bound at run-time using late binding, which requires no declaration of Properties and Methods. However, for this very reason, the validity of these references can not be verified by PowerBASIC at the time the program is compiled."

        So unless you use OBJECT XXX ...., how does the compiler know what method string to pass to the undeclared object.


          In PB, there are to kind of statements to assign a value to a property, OBJECT LET and OBJECT SET, and the two have the same syntax. Therefore, you need to specify LET or SET, or the compiler does not know which one to use. Personally, I never have liked that syntax, but it is what Bob did choose.

          BTW. Do you have inspected that OCX with a TypeLib Browser to see if it has a dual interface? Direct interface calls are faster than Automation and don't usually require the use of variants.


            Howdy, Stuart!
            So, I guessed right, about it being a compile time issue. Thanks for pointing out the Help comments that confirm the source of the problem. I'll have to learn more about the topic to have a better opinion of whether another syntax could be possible. As you said, it is what it is!

            Howdy, Jose!

            Thanks for the comments!

            I must plead inexperience on the matter, having not used the PowerBASIC COM browser before.

            How would I know if a dual interface was available from looking at VideoCapX in the PowerBASIC COM Browser?

            Under Class IDs, I see only two CLSIDs - one for the OCX and one for events. Does that apply a single interface?

            Under Interface Identifiers I see more entries, but they seem to apply to the DVD capabilities of the OCX.

            Can you clarify? Is there a control you know to have a dual interface that I could compare with?


              Use a decent browser:

              Witrh it, if you click MSADO15.DLL (ADO), which is an OCX (although not visual) you will see at the bottom of the left side TreeView: Interfaces, Dual interfaces, Dispatch interfaces, Dispatchable interfaces and Event interfaces. If there is not an entry for Dual interfaces in the inspected OCX type library, then it can't be used with direct interface calls.


                Thanks, Jose!

                I used the browser you suggested. The VideoCapX OCX does not have an entry for Dual interfaces.