Item Reference Variables in Omnis Classic

In Omnis Classic, reference variables behave a little differently from other variable types.
You don’t need to call isnull() to see if a reference is valid — you can test it directly.


Manual Statement

From the Omnis Classic manual:

A reference variable which you have not set is empty.
A reference you have not set to a value returns false.

Example from the manual:

Local variable LREF (Reference)

If LREF
   OK message {Reference is true}
Else
   OK message {Reference is false}
End If

Calculate InvoiceTotal as LREF
; InvoiceTotal is now also empty

Why This Works


Practical Example

Say you want to check if a menu’s $procs collection exists before using it.

Verbose approach (using isnull):

If not(isnull(LI_Item))
   Calculate LB_Ok as kTrue
Else
   Calculate LB_Ok as kFalse
End If

Simpler Classic approach:

If LI_Item
   Calculate LB_Ok as kTrue
Else
   Calculate LB_Ok as kFalse
End If

Or even shorter:

Calculate LB_Ok as LI_Item

Important Notes


Summary:
In Omnis Classic, testing an item reference is as simple as If LI_Item — no extra functions needed.