|
Properties can be used only when programming user Indicators. In any other circumstance it will be possible to use this tool otherwise the command interpreter will alert promptly.
These properties will be shown, along with other default properties, on the control panel for the specific user indicator where it will be possible to modify the value, exactly like any other indicator property.
In the picture of the control panel is selected the user indicator "OscillatorMM". In this indicator has been programmed only the property "PERIOD" (the others are default properties). The period value can be set from the Control Panel, like any other property.
Now we are going to see how to program the property.
A property is defined first of all by its name and type, and it will start with the keyword Property and finish with the keyword EndProperty. The syntax of the first line is the following:
Property "property_name"() As " property_type"
There are 2 property types available: Numeric (property is a number), Date (property is a date).
let's see an example:
Property Period() As Numeric
where "Period" is the name of the numeric property. Note that the round parentheses after the name are not mandatory. In fact it could have been written as:
Property Period As Numeric
To finish writing the property we have seen that the keyword EndProperty has to be used.
Property Period() As Numeric
EndProperty
For all properties it is possible to insert a list of values to choose from. In this case on the control panel, the properties in question will appear like a combo box and it will be possible to valorize it only with one of the element which appear on the list.
Every element is defined with this syntax:
List( name, value)
The value as to be of the same type as the one of the property, and in this case the round parentheses must be used.
Lets see the example updated:
Property Period() As Numeric List ( Average10, 10 ) List ( Average100, 100 ) List ( Average200, 100 ) EndProperty
Three elements have been added to the list. In practice the property can only assume values of 10, 100, 200.
Now we have to define the "Default" value of the property, the value it will assume on the Control Panel, before it is set in any way. The syntax is the following:
Default ( default value )
The default value has to be of the same type as the one of the property, round parentheses must be used.
In the example, because the property already has a list of possible values, it has be one of them:
Property Period() As Numeric List ( Average10, 10 ) List ( Average100, 100 ) List ( Average200, 100 ) Default (200) '200 is one of the value on the list EndProperty
The property is now ready!
What if we do not want any more to have the list to choose from? The property should have a text box where it will be possible to write the property value by hand. In this case, the program will be just like that:
Property Period() As Numeric Default (200) '200 is one of the values on the list EndProperty
Now an additional valid range could be added, so only certain values will be accepted.
The syntax to define the range is:
Range ( lowest_value, heightest_value )
where lowest_value and highest_value have to be of the same type of the property, round parentheses must be used.
It is not mandatory to insert both values. If the validity range includes all numbers grater than zero, the highest margin may not be written.
Lets see the example updated:
Property Period() As Numeric Range (0, 200) 'valid range is from 0 a 200 Default (200) '200 is one of the values on the list EndProperty
NB Inserting a Range condition when a List is defined, the first will be ignored.
|