8.7.2 DEFINE_PTY Examples
Example 1
This command defines a property STREETNO for Form B. When an owner form sets the value of this property, the value is assigned automatically to the #address1 field on Form B. When an owner form queries the value of this property, the current value of the #address1 field on Form B is returned.
define_pty name(STREETNO) set(*auto #address1) get(*auto #address1)
An owner form can now set the value of the property like this:
set COM(#FORMB) STREETNO('58 Surrey St')
Or if it contains an #ADDRESS1 field, it can pass the current value of the field:
set COM(#FORMB) STREETNO(#ADDRESS1)
Example 2
Define a property that gets a reference to button #PHBN:
Define_Pty Name(Button1) Get(*Reference #Phbn_1)
The Button1 property of the owner component can then be used to access #Phbn_1, for example to change its Parent property:
Set Com(#COM_OWNER.Button1) Parent(#GPBX_1)
Example 3
Get a reference to a collection:
Define_Pty Name(TheCollection) Get(*Collection #Collection)
It then iterates through the collection using the reference and adds the value and the caption of the collection items to a list:
For Each(#Current) In(#COM_OWNER.TheCollection) Key(#CurrentKey)
Change Field(#STD_COUNT) To('#CurrentKey.Value')
Change Field(#STD_DESCS) To('#Current.Caption')
Add_Entry To_List(#GRID_1)
Endfor