Studio Techniques

Objects

Modern computer programming languages allow applications to be built using re-usable containers of variables (properties) and procedures (methods) called objects. Omnis Studio implements many of it's standard components ("formats" in Classic) as object classes, and enables developers to implement their own, in order to extend the hierarchical model for an application. This has benefits of code re-use and improved maintainability. The area of Object Oriented Omnis (OOO) has become a dark art in its own right, with various tricks for improved efficiency in the implementation of inheritance, polymorphism, dynamic binding and so on. But, it's worth noting that you DON'T HAVE TO USE OBJECTS, and a "traditional" Omnis Classic procedural approach will still work nicely, allowing development teams to come to terms with OOO at their own rate.

For a more detailed introduction to OOO, you can view an excellent PowerPoint presentation, prepared by Geir Fjaerli and Mark Phillips.

Notation

There is more of an emphasis on programming in Omnis Notation ($dollar commands) when using Studio, SQL and the Web. The power of notation has been increased, and you can now do virtually anything using the little dollars. For example, compare the following code:-

Both of the above examples will work with either Omnis Classic or Studio, but the latter is more future-safe, as it doesn't use either the current list, or the current list line (#L). In the scope of a multi-user web application server this can be very important.

Lists

Manipulating lists is central to data handling and presentation, and Omnis Studio contains some powerful list features:-

Smartlists
You can specify a list variable as a smartlist, which lets you filter the list in in incremental stages, then revert to unfiltered versions, or previous filter levels. This type of list becomes especially useful when dealing with SQL classes.


Do MyList.$smartlist.$assign(kTrue)
Do MyList.$filter($ref.Value>5000)
;List contains only records > $5,000
Do MyList.$filter($ref.Date<"1 JAN 2000")
;List contains only records before 2000
Do MyList.$unfilter(1)
;List back to first filter level
Object Lists
Combining object orientation with lists can give you powerful collections of object references. For example, let's imagine a bank account object with a $balance property and a $bonus method. A procedure to grant a bonus to all bank accounts with a balance above 5,000 could use a list of account objects:-
For %i from 1 to MyAccountList.$linecount
  If MyAccountList.[%i].$balance()>5000
    Do MyAccountList.[%i].$bonus()
  End if
End for
$sendall
My favourite Omnis command, this allows you to send one command or set of instructions to each line of a list, or indeed each member of a group (such as fields on a window). So, we could replace the above account bonus method with:-


Do MyAccountList.$sendall($ref.$bonus(),$ref.$balance()>5000)
The line above calls the $bonus method for each object in MyAccountList whose $balance is greater than 5000. Just for fun, consider the assignation of the #3 value in the examples above, where we step through each list line in a loop. 5 lines of code in 4GL, 3 lines in simple notation, or ...


Do #L1.$sendall($ref.#3.$assign((%i.$assign(%i+1))*#L1.[%i].#1*#L1.[%i].#2)
As well as amusing programmers, this can be a powerful feature


Omnis Studio contains many more powerful and interesting features. For more information, see Further Reading

Document prepared 8 AUG 2000 by Tim Stewart