InitialValue Meta-Tag

See Also: Class Member Meta-Data Tags

Purpose

Indicates the initial value of a property defined in the current class.

Applies To

Properties

Syntax

{ InitialValue={Value} }

Where {Value} is the initial value of the property.

String values should be enclosed in quotes:

{ InitialValue="My Company Name" }

Property String psCompanyName

Complex values should be comma-separated:

{ InitialValue=20, 100 }

Property Complex Size

Use

Initial values that are not set in the property declaration cannot be read by the code parser. To indicate the initial value of a property, use the InitialValue class member meta-data tag.

To indicate that the initial value of a property is changed in a subclass of the class where the property was originally declared, use the OverrideProperty class meta-data tag.

Example 1:

Consider the following code:

Property String psFirstName "John"

Since the initial value of the property is set in the property declaration, the code parser will be able to read it. Sometimes, however, the initial value of a property cannot be set on the declaration line.

Example 2:

Consider the following code:

Property String psFirstName

Assume that the initial value of psFirstName is being set to "John" in some other method in the class. You can indicate that initial value here as such:

{ InitialValue="John" }

Property String psFirstName

 

Example 3:

Consider the following code:

Class cContact is a cObject

 

    Procedure Construct_Object

        forward send Construct_Object

 

        { Visibility=Private }

        Property String psPrivateFirstName

    End_Procedure

 

    { MethodType=Property }

    Procedure Set psFirstName String sFirstName

        set psPrivateFirstName to "John"

    End_Procedure

 

End_Class

The Procedure Set psFirstName method declares the property psFirstName. Since the value of the property is set in this method, the code parser will not be able to read its initial value.

In this case, the InitialValue meta-data tag is used to indicate the property's initial value, as shown below.

Class cContact is a cObject

 

    Procedure Construct_Object

        forward send Construct_Object

 

        { Visibility=Private }

        Property String psPrivateFirstName

    End_Procedure

 

    { MethodType=Property }

    { InitialValue="John" }

    Procedure Set psFirstName String sFirstName

        set psPrivateFirstName to "John"

    End_Procedure

 

End_Class

Of Special Note

The InitialValue class member meta-data tag is inherited. If a superclass property has a specific initial value (e.g. "John"), the same property in subclasses of that class will have the same initial value (e.g. "John"), unless it is explicitly changed in that subclass.