Ask Your Question

Is there are value for a null object in LoBasic?

asked 2018-03-01 17:24:33 +0200

ptoye gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-03-01 22:38:54 +0200

Ratslinger gravatar image

Hello @ptoye,

Here is a simple example:

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

Function TryCreateObject(number)
    Dim oRectangle as Object
    If number > 6 then
        oRectangle = createObject("")
    TryCreateObject = oRectangle
End Function
edit flag offensive delete link more


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("")
    TryCreateObject = What do I put here???
End Function
ptoye gravatar imageptoye ( 2018-03-02 10:36:02 +0200 )edit

"What do I put here???"

Nothing :)

Seriously, TryCreateObject = Nothing

librebel gravatar imagelibrebel ( 2018-03-15 17:14:59 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-03-01 17:24:33 +0200

Seen: 47 times

Last updated: Mar 01 '18