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
- An unset or empty reference evaluates to false in a conditional expression.
- A valid reference (pointing to something) evaluates to true.
- This behaviour applies to all Item reference variables (menus, toolbars, fields, etc.).
- No need for
isnull()in Classic unless you want to explicitly test for null.
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
-
If Omnis creates a valid but empty collection (e.g.
$menusexists but has$count=0),
the reference will still evaluate as true.
In that case, you may also need to check$count:If LI_Item & LI_Item.$count>0 ; Safe to proceed End If -
This behaviour is specific to Omnis Classic.
Later Omnis Studio versions handle references differently and may require$isref()or other checks.
Summary:
In Omnis Classic, testing an item reference is as simple as If LI_Item — no extra functions needed.