Announcement

Collapse
No announcement yet.

Optional Parameters ?

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

  • Michael Mattias
    replied
    > have just found that MCM's code is kind of documented in the Help of PBWin9.01:

    Funny, you picked one of the "documentation complaints" I sent in.

    So, a specific COM error number is usually a COM specific error? Thank goodness for that info: Who'd-a-thunk-it?

    Leave a comment:


  • Robert Wallace
    replied
    Many thanks,

    Bob

    ----------------------------------------------------
    Added later.

    I have just found that MCM's code is kind of documented in the Help of PBWin9.01:
    LET vrntvar = ERROR numr

    This form assigns a specific COM error number, which is usually a COM specific error, such as %E_NOINTERFACE, etc.
    Last edited by Robert Wallace; 31 Jul 2009, 02:48 AM.

    Leave a comment:


  • José Roca
    replied
    "If an optional argument to an Automation method is left blank, do not pass a VARIANT of type VT_EMPTY. Instead, pass a VARIANT of type VT_ERROR with a value of DISP_E_PARAMNOTFOUND."

    See: http://msdn.microsoft.com/en-us/library/ms221627.aspx

    Leave a comment:


  • Michael Mattias
    replied
    >. Is MCM's method documented anywhere?

    Not that I could ever find .... but there IS a 'document improvement suggestion' I submitted to put this exact information on both the LET [with Variants] and the OBJECT CALL pages of the help file.

    I orginally got this info here (sorry can't recall from whom) ; it worked just ducky with ADO; or maybe it was Excel. Or maybe it was both.

    MCM

    Leave a comment:


  • Robert Wallace
    replied
    Many thanks for the explanation - I am puzzled by a couple of things:

    1. Is MCM's method documented anywhere?

    2. Does a called routine, expecting an optional variant containing an Array of two elements, interpret a large negative number as something to be ignored?

    Bob

    Leave a comment:


  • Jeff Blakeney
    replied
    When you use the OPTIONAL clause in a procedure's parameter list, that parameter and all parameters to the right of it are optional as well. When calling the procedure with optional parameters, you still need to supply them in the same order as they were defined. In your case, PB_To and By are both optional so you can call it with myMethod(), myMethod(PB_To) or myMethod(PB_To, By) but you can't call it with myMethod(By) as your procedure would be using the By as PB_To so you won't get the results you expect.

    You have to supply somethng for PB_To even if you only intend to pass By and I think Michael's post addresses that.

    Leave a comment:


  • Michael Mattias
    replied
    Code:
    LOCAL vMyOptionalParamIamNotPassing AS VARIANT
    
       LET  vMyOptionalParamIamNotPassing = ERROR %DISP_E_PARAMNOTFOUND
    
       OBJECT CALL myMethod (vMyOptionalParamIAmNotPassing, [ other params])
    MCM

    Leave a comment:


  • Robert Wallace
    started a topic Optional Parameters ?

    Optional Parameters ?

    How do I code an OBJECT CALL that has an optional parameter? If I place both parameters the specification says that the second parameter will be ignored. I want to use the second parameter only.

    From the "inc" file:
    Code:
    Member Call Move <1836021349> (Opt In PB_To As Variant<0>, Opt In By As Variant<1>)
    My Code:
    Code:
    OBJECT CALL myRectangle.move(,vtempby)
    or
    Code:
    OBJECT CALL myRectangle.move(NOTHING,vtempby)
    generate "Syntax error"

    This code compiles but with the wrong result:
    Code:
    OBJECT CALL myRectangle.move(vtempto,vtempby)
    Last edited by Robert Wallace; 30 Jul 2009, 10:03 AM. Reason: syntax
Working...
X