OverrideProperty Meta-Tag

See Also: Class Meta-Data Tags

 

Purpose

Used to specify that the information in this tag set should be applied to the property name for this class, where the property is an inherited property, not one defined in the current class.

Syntax

 

{ OverrideProperty={PropertyName} {ClassMemberMetaDataTagName}=MyValue }

where:

 

Note: OverrideProperty must be the first name in the tag-set and all other name / value pairs in the tag set will be applied to PropertyName.

Use

This is used to change values of class member meta-data tags DesignTime, InitialValue or Visibility for a property in a subclass.

Sometimes, the value of a property meta-data tag is different in a subclass of the class where the property was originally declared. To indicate this, use the OverrideProperty class meta-data tag. (An exception to this rule is an initial property value that is changed inside the Construct_Object method of a subclass using a set statement.)

To declare the meta-data tag value of a property that is declared in the current class, use the appropriate class member meta-data tag.

OverrideProperty must be used to override the value of any class member meta-data tag for properties in the current subclass. To overwrite the value of functions, procedures or procedure sets, use OverrideFunction, OverrideProcedure or OverrideProcedureSet, respectively. Using the wrong override type will result in an error and/or unexpected behavior.

 

Example:

Sometimes the initial value of a property is changed in a subclass of the class where the property was originally declared.

Consider the following code:

Class cBeverage is a cObject

 

    Procedure Construct_Object

        forward send Construct_Object

        Property String psFavoriteBeverage "Juice"

    End_Procedure

 

End_Class

 

Class cHotBeverage is a cBeverage

 

    Procedure InitializeClass

        Set psFavoriteBeverage to "Tea"

    End_Procedure

 

End_Class

 

The property psFavoriteBeverage is declared in class cBeverage and initialized to "Juice". In cHotBeverage, a subclass of cBeverage, the initial value of the inherited property is changed to "Tea".

The code parser will not be able to read the initial value of a property whose initial value is set in a method. To allow the code parser to read the initial value of the property in the above example, the meta-data tag InitialValue has to be set to the property's initial value. However, since the property is inherited and not declared in the subclass cHotBeverage at all, the OverrideProperty meta-data tag needs to be set to indicate that an inherited property is being overridden.

Class cBeverage is a cObject

 

    Procedure Construct_Object

        forward send Construct_Object

        Property String psFavoriteBeverage "Juice"

    End_Procedure

 

End_Class

 

{ OverrideProperty=psFavoriteBeverage InitialValue="Tea" }

Class cHotBeverage is a cBeverage

 

    Procedure InitializeClass

        Set psFavoriteBeverage to "Tea"

    End_Procedure

 

End_Class

 

Example:

An exception to the rule in the example above is a property defined in a superclass whose initial value is changed in a subclass via a set statement in Construct_Object (and only in Construct_Object). The Studio’s meta-data parser parses inside of Construct_Object looking for set statements. If it encounters a set statement, it will set the property’s initial-value to that value.

For example, the following code does not require an OverrideProperty and InitialValue meta data tag to initialize the value of psMyString to "Hi" for the cFooSub class.

Class cFoo is a cObject

    Procedure Construct_Object

        Forward Send Construct_Object

        Property String psMyString "Hello"

    End_Procedure

End_Class

 

Class cFooSub is a cFoo

    Procedure Construct_Object

        Forward Send Construct_Object

        Set psMyString to "Hi"

    End_Procedure

End_Class

 

Object oFoo is cFooSub

    

End_Object

 

Example:

If you have conditional code in a constructor such as:

Class cFooSub is a cFoo

    Procedure Construct_Object

        Forward Send Construct_Object

        Set psMyString to "How are you"

        If (SomeValue) Begin

            Set psMyString to "Hello, there"

        End

    End_Procedure

End_Class

The Studio will do its best to update an initial value. In this case, it will use the last value inside the if statement ("Hello, there"). If this is not what you want, you can still use InitialValue to set it to the value you want:

{ OverrideProperty=psMyString InitialValue="How are you" }

Class cFooSub is a cFoo

    Procedure Construct_Object

        Forward Send Construct_Object

        Set psMyString to "How are you"

        If (SomeValue) Begin

            Set psMyString to "Hello, there"

        End

    End_Procedure

End_Class

 

Example:

You can override the visibility of an inherited property from a superclass. Setting the Visibility meta-data tag of a property to Private can "hide" a the property from all Studio design time access, including the Object Properties window and CodeSense, for the class in which it is overriden.

For example, the following code overrides the visibility of the inherited property psMyString from public (the default) in the superclass cFoo, where it is defined, to private in the subclass cFooSub.

Class cFoo is a cObject

    Procedure Construct_Object

        Forward Send Construct_Object

        Property String psMyString

    End_Procedure

End_Class

 

{ OverrideProperty=psMyString Visibility=Private }

Class cFooSub is a cFoo

End_Class

 

Of Special Note

The class member meta-data tag values that are set by OverrideProperty may be inherited. See the documentation for the class member meta-data tag you are overriding to see if it is inherited.