DEFINE CLASS Command - PEMName_COMATTRIB Clause

Specifies type library attributes and values for PEMName_COMATTRIB properties or methods. The features described in this section applies only to OLEPUBLIC classes and is used to specify additional information, such as a description or read-only attribute, about the property or method that you want written to the COM type library.

Note

Unlike Access and Assign methods, PEMName_COMATTRIB properties are marked as hidden automatically and are not accessible in Visual FoxPro. They are strictly for use by Visual FoxPro during the build process when writing to a COM type library.

[PEMName_COMATTRIB = nFlags | DIMENSION PEMName_COMATTRIB[numElements]
   [PEMName_COMATTRIB[1] = nFlags
        PEMName_COMATTRIB[2] = cHelpString
        PEMName_COMATTRIB[3] = cPropertyCapitalization
        PEMName_COMATTRIB[4] = cPropertyType
        PEMName_COMATTRIB[5] = nOptionalParams]]

Parameters

  • [ PEMName_COMATTRIB = nFlags| DIMENSION PEMName_COMATTRIB[numElements]
    Specifies an nFlags value for a PEMName property or method or uses the DIMENSION command to create a property array that contains type library attributes for the PEMName property. When creating an array, numElements specifies the number of elements in the array up to 5.

    The following table describes the elements in the array.

    COMATTRIB element Description Type

    1

    Attribute flags.

    Number

    2

    Help string.

    String

    3

    Capitalization.

    String

    4

    Property type.

    String

    5

    Number of parameters.

    Note

    If you specify fewer than the actual number of parameters, the number greater than those declared are optional.

    Number

    Note

    For invalid values or types in the PEMName_COMATTRIB array, Visual FoxPro generates an error. Empty elements use default values.

  • nFlags
    Specifies attribute flags for the PEMName property or method as it appears in the type library. The following table describes the valid flags.

    nFlags value #DEFINE Description

    0x1 (1)

    COMATTRIB_RESTRICTED

    The property or method should not be accessible from macro languages. This flag is intended for system-level functions or functions that type browsers should not display.

    COMATTRIB_RESTRICTED means that macro-oriented programmers should not be allowed to access this member. These members are usually treated as _HIDDEN by tools such as Visual Basic, with the main difference being that code cannot bind to those members.

    0x40 (64)

    COMATTRIB_HIDDEN

    The property or method should not be displayed to the user, although it exists and is bindable.

    COMATTRIB_HIDDEN means that the property should never be shown in object browsers, property browsers, and so on. This function is useful for removing items from an object model. Code can bind to the member, but the user will never know that the member exists.

    0x400 (1024)

    COMATTRIB_NONBROWSABLE

    The property or method appears in an object browser but not in a properties browser.

    COMATTRIB _NONBROWSABLE means that the property should not be displayed in a properties browser. It is used in circumstances in which an error would occur if the property were shown in a properties browser. Early and late binding impose differing access restrictions. Early-binding clients will not be able to write to a read-only property, nor read from a write-only property because there will not be an entry in the vtable. Late-binding clients can still access a propertyget on a write-only or a propertyput on a read-only PEMName.

    0x100000

    COMATTRIB_READONLY

    The property is read-only. Applies only to Properties. Equivalent to a PropertyGet.

    Note

    Using both COMATTRIB_READONLY and COMATTRIB_WRITEONLY is equivalent to using neither.

    0x200000

    COMATTRIB_WRITEONLY

    The property is write-only. Applies only to Properties. Equivalent to a PropertyLet.

    Note

    Using both COMATTRIB_READONLY and COMATTRIB_WRITEONLY is equivalent to using neither.

  • PEMName_COMATTRIB[2] = cHelpString
    Specifies a string value to store in the type library for the PEMName property. For methods, use the HELPSTRING cHelpString clause.
  • PEMName_COMATTRIB[3] = cPropertyCapitalization
    Specifies the property name as a string value as it should appear in the type library. All capitalization is preserved. If this setting is omitted, Visual FoxPro writes the property to the type library in all uppercase.
  • PEMName_COMATTRIB[4] = cPropertyType
    Specifies the property data type as a string value as it appears in the type library and functions the same as the ASType clause. Applies to Properties only.
  • PEMName_COMATTRIB[5] = nOptionalParms]]
    Specifies the number of optional parameters in a method. For example, if this value is 2 for a method with 5 parameters, then the last 3 are optional. Applies to Methods only.

    For late-binding clients, default values for optional parameters will still be False (.F.), and the PCOUNT( ) function accurately reflects the true number of passed parameters. For early-bound clients, default values for optional parameters will always be set to an empty string (""), and PCOUNT( ) will always return the total number of parameters for the method, not the number passed in.

Remarks

The following code shows a summary of the main clauses of the DEFINE CLASS command:

DEFINE CLASS Clause
   [Property_Definition_Clause]
   [PEMName_COMATTRIB Clause]
   [ADD OBJECT Clause]
   [IMPLEMENTS Clause]
   [Function_Procedure_Definition_Clause]
ENDDEFINE

For more information and full syntax, see DEFINE CLASS Command. For more information about a particular clause of the DEFINE CLASS command, see the following topics:

Example

The following example demonstrates how to define an array of type library attributes using the DIMENSION PEMName**_COMATTRIB** clause:

#INCLUDE foxpro.h
DEFINE CLASS myOLEClass AS Custom OLEPUBLIC
   MyProperty = 5.2
   * Set COM attributes for MyProperty.
   DIMENSION MyProperty_COMATTRIB[4]
   myProperty_COMATTRIB[1] = COMATTRIB_READONLY
   myProperty_COMATTRIB[2] = "Help text displayed in object browser"
   myProperty_COMATTRIB[3] = "MyProperty"  && Proper capitalization.
   myProperty_COMATTRIB[4] = "Float"        && Data type
ENDDEFINE

However, if you want to set only the nFlags element, you do not need to create an array:

#INCLUDE foxpro.h
DEFINE CLASS myOLEClass AS Custom OLEPUBLIC
   MyProperty = "Test"
   * Set the only the nFlags attribute for MyProperty.
   myProperty_COMATTRIB = COMATTRIB_READONLY
ENDDEFINE

See Also

Reference

:: Scope Resolution Operator
ADD CLASS Command
CREATE CLASS Command
CREATE CLASSLIB Command
DODEFAULT( ) Function
EVENTHANDLER( ) Function
GETOBJECT( ) Function
MODIFY CLASS Command
RELEASE CLASSLIB Command

Other Resources

Commands (Visual FoxPro)