How to set an initial value for a property field
This ‘How-to’ provides information on how to set an initial value for a property (field). The default value of a property is ‘blank’ (no value).
The following development process demonstrates how to add a simple script to a Data class to set the initial value of a property (MYPROP1) to today’s date:
Open your Data class.
Select the General tab >Scripts block and set the following field values:
Type: Select a type appropriate for your script.
Scripts Leave the default code displayed. This is automatically generated using the class code and script type. Alternatively, enter a unique code for your script.
Running order:. Leave the numeric displayed. This is automatically generated to control the order in which the '$PROPERTIES' and '$METHODS' labels are called in the event. Alternatively, enter the running order code for your script.
To add your script, right-click the Scripts code and select Processing editor from the selection menu. Enter the following code:
# Properties for MYCLASS$PROPERTIESCase CURPROWhen "MYPROP1" : Gosub MYPROP1EndcaseReturn# Action to be carried out by MYPROP1$MYPROP1Case ACTION# Set default date as todayWhen "INIT"this.MYPROP1 = date$EndcaseReturn
4. Save your script.
5. Save and validate your Data class.