Omnis Technical Note TNNO0017 October 2008

Using custom properties with $sendall

For Omnis Studio 3/4
By Andreas Pfeiffer

Omnis Studio is an object oriented tool which allows you to set properties and to create your own interfaces to objects. The $sendall method is very powerful since it allows you to send a message to several members of a group. For example:

Do $cinst.$objs.$sendall($ref.$enabled.$assign(kTrue)

would enable all objects in the group $cinst.$objs, that is, the $enabled property for all the objects of the current instance (assuming they are not nested) would be set to kTrue allowing input by the user. This of course is very useful, but it could be possible that you only want to enable certain, but not all, objects in the instance. You could do this by adding your own properties to certain objects and assigning to these properties.

To do this, create your own public method in the respective object(s), for example, you could add a method called $willEnterable. This method should return kTrue as the only line, that is:

Quit Method {kTrue}


You could regard such a method as a custom or "quasi property" since it has a boolean state, not an action like standard methods. Now you can use a $sendall method to enable, or "switch on", only those objects that, firstly, have the $willEnterable method and, secondly, the method returns kTrue. To do this you would need to execute the following $sendall() method:

Do $cinst.$sendall($ref.$enterable.$assign(kTrue),$ref.$willEnterable())

The second parameter of the $sendall method, in this case $ref.$willEnterable(), works like a filter. When the $willEnterable "property" for a particular object returns kTrue, the object will be switched to Enterable - if it is not present or returns false the object remains disabled. Please note you must include the parenthesis after the $willEnterable method name to ensure it is evaluated at runtime.