Metadata in Subclasses
The Studio’s meta-data parser now 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. This removes much of the need for the OverrideProperty / InitialValue metadata tags in sub-classes. This means that a changed property value in a sub-class is now picked up without having to remember to write an InitialValue meta-tag.
Example
Assume the following code:
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
Prior to 14.1, if you looked at the property panel’s value of psMyString for the object oFoo, it would be “Hello” and not “Hi”. The parser did not look for set property changes in the sub-class constructor. To make this work properly, you had to remember to create a meta-tag for the sub-class as follows:
{ OverrideProperty=psMyString InitialValue="Hi" }
Class cFooSub is a cFoo
Procedure Construct_Object
Forward Send Construct_Object
Set psMyString to "Hi"
End_Procedure
End_Class
Of course, no one ever remembered to do this, and even if you tried, it was very easy to get wrong. Now the Studio will do this for you, and the value will be correct.
Conditional Code in Constructors
This raises the question of what happens when 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
It was this kind of complexity that caused us to not attempt to look at set statements in constructors. In 14.1, we've changed our mind. 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
In other words, the normal cases are handled by the Studio, and the InitialValue meta-tag only needs to be used to handle exceptions.