Read-Only Access to Collections

Source Code for the Collection Programming Example

To establish automatic read-only access to a collection you can use the DEFINE_PTY reference to the collection using the *Collection keyword for the GET parameter.

This statement creates a collection:


And this statement creates a read-only reference to it:

Define_Pty Name(TheCollection) Get(*Collection #Collection)

You can use these kinds of properties to access a collection to do look-ups or to loop through the collection contents. This property does not allow you to change the contents of the collection. The collection reference can also be used to allow other owner components access to the collection without having to create a payload and pass references.

In this example selected buttons are added to a collection when the Insert button is clicked.  The Iterate Collection button iterates the actual collection and adds its contents to the list view, the Iterate Reference button accesses the contents of the collection using the reference set in the property and adds its contents to the list view (so the displayed items are always the same):