Is there are value for a null object in LoBasic?

I want to write a function which returns either an object if it can, or a null object if it can’t. The AOO wiki seems to be silent on the subject - the language definition waxes lyrical about how object-oriented it is, but does not even mention objects. Other pages tell me how to create objects, but nothing about the null object.

Can this be done? It should be simple, and is in properly OO languages which have the concept built-in.

Hello @ptoye,

Here is a simple example:

Sub MyRoutine
    oRectangle = TryCreateObject(3)
    if  ISNULL(oRectangle) then
        msgbox "Null"
    else
        msgbox "Not Null"
    end if
End Sub

Function TryCreateObject(number)
    Dim oRectangle as Object
    If number > 6 then
        oRectangle = createObject("com.sun.star.awt.Rectangle")
    EndIf
    TryCreateObject = oRectangle
End Function

Thanks I’ve not tried this yet, but it looks as if it should work. Presumably the Dim statement creates a null object. Shame about the lack of documentation.

I was trying something like

Function TryCreateObject(number)
   If number > 6 then
    TryCreateObject= createObject("com.sun.star.awt.Rectangle")
  Else
    TryCreateObject = What do I put here???
  EndIf   
End Function

“What do I put here???”

Nothing :slight_smile:

Seriously, TryCreateObject = Nothing