Tips   >   Notation   >   Notation References

Notation References

A reference is a variable of item reference type which is pointing to something in Omnis. A reference could be pointing to a window instance, window class, window object, object method, list variable...

If you are using notation, you will either write very long notation strings or use references and write much shorter notation strings. You can use references to make your code more stable and efficient.


I still get confused by references. When to include $ref, when not to, and a few other issues. The following was taken from a list server posting by Tim Stewart. It should help your understanding.

Tim wrote a quick overview of the various references. The posting is listed in the sample code below.

Referencing Objects inside Containers

Window objects inside container objects can be referenced notationally directly as window objects. You can leave the 'containers' out of the notation string, and the reference will still be valid. This also applies to subwindow window instance fields. The subwindow's fields become part of the parent window

All of the following references are valid and will work

Set reference rField to $cinst.$objs.SCROLLBOX.$objs.NESTEDSCROLLBOX.$objs.ENTRYFIELD
Do rField.$forecolor.$assign(kRed)

Set reference rField to $cinst.$objs.SCROLLBOX.$objs.ENTRYFIELD
Do rField.$forecolor.$assign(kGreen)

Set reference rField to $cinst.$objs.ENTRYFIELD
Do rField.$forecolor.$assign(kCyan)

Set Reference in $construct

If you are going to use notation to manipulate the properties of any window object, an easy way to get a reference to that object is:

  1. Add an item reference instance variable by the name of the field to the window class. (irFieldName)
  2. Add a $construct method to the object, if one does not exist already.
  3. As the first, and usually only, line of code in the $construct:

    Set reference irFieldName to $cfield

This will set the ivar reference to the correct field in a manner that is impervious to renaming of the object or even copying and pasting the object into another window.


I might have a treelist object in a window and a class method named $buildTreeList.

The $construct method of the treelist object has the following line of code in it:

Set reference irTree to $cfield

From the $buildTreeList method I can execute any treelist methods and set any treelist properties using the ivar irTree. If later on I move the treelist object into a scroll box or a tab pane object the $buildTreeList code does not break because the treelist object's $construct method always correctly sets the reference for irTree.

Set Reference with $findname

There are several ways which you can get or set a reference to something.

  1. Set reference Omnis command
  2. Return a reference from a notational string.

Thanks to Mark Phillips I rarely use the "Set reference" Omnis command anymore.

Mark taught me about $findname and then testing the return value for null. I've been using it ever since.

One advantage of using $findname is that it doesn't get messed up by $ characters in a public method name.

The following Set reference will fail.
Set refererence $cclass.$methods.$construct to rMethod

Using $findname won't fail.
Do $cclass.$methods.$findname('$construct) Returns rMethod


The $cclass.$methods.$findname notation won't find any inherited superclass methods when you are in the subclass