Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

7.34.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.

Code Block
define_pty name(STREETNO) set(*auto #address1) get(*auto #address1)

An owner form can now set the value of the property like this:

Code Block
set COM(#FORMB) STREETNO('58 Surrey St')

...

Code Block
set COM(#FORMB) STREETNO(#ADDRESS1)

Example 2

Define a property that gets a reference to button #PHBN:

Code Block
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:

Code Block
Set Com(#COM_OWNER.Button1) Parent(#GPBX_1)

Example 3

Get a reference to a collection:

Code Block
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:


Code Block
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