Call a Method with an [optional] Parameter

In order to specify that [optional] VARIANT parameters are missing, you need to pass a VARIANT which has its variant type set to VT_ERROR and the error code set to DISP_E_PARAMNOTFOUND. The jSegue Java class com.moesol.bindings.platform_sdk.component_services.VARIANT contains a public static final field named PARAMNOTFOUND that can be used. Also, as a convience, jSegue converts null into VARIANT.PARAMNOTFOUND. So, you can simply pass null for [optional] VARIANT parameters. If you require an empty VARIANT then you can use VARIANT.EMPTY

public void testCallOptional() {
    m_dual.CallWithOptional(VARIANT.PARAMNOTFOUND);
    m_dual.CallWithOptional(null); // null defaults to VARIANT.PARAMNOTFOUND 
    try {
        m_dual.CallWithOptional(VARIANT.EMPTY);
        fail("Should have thrown");
    } catch (COMException e) {
    }
}

$Id: call_optional.html 3769 2007-06-08 19:06:43Z hastings $