Return value of a lisp callable function

Return value of a lisp callable function

Anonymous
Not applicable
1,323 Views
7 Replies
Message 1 of 8

Return value of a lisp callable function

Anonymous
Not applicable
Hi,

I was wondering if it's possible to return a plain nil (as opposed to a list
containing just nil) from a lisp callable function.
The other night I was experimenting a bit and the only thing I could think
of was this

Return New ResultBuffer(New TypedValue(LispDataType.Nil))

I'm also wondering if there's a way to typecast a VB boolean value to
LispDataType.T_atom or LispDataType.Nil
For now I'm doing something like this:

If Condition Ten
SomeTypedValue = New TypedValue(LispDataType.T_atom)
Else
SomeTypedValue = New TypedValue(LispDataType.Nil)
End If

Thanks in advance
and beg pardon if these are stupid questions.
0 Likes
1,324 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
These aren't stupid questions, if for no other reason because there is virtually no documentation on any of this.

A method marked with the LispFunction attribute should return a ResultBuffer only if you are returning a list.

If you are returning an atom, you just return that value directly.

For example, this method will return the symbol T:

[LispFunction("foo")]
public static object Foo( ResultBuffer args )
{
return true;
}

and this will return the integer 99:

[LispFunction("bar")]
public static object Bar( ResultBuffer args )
{
return 99;
}

and this will return the string "Hello":

[LispFunction("baz")]
public static object Baz( ResultBuffer args )
{
return "Hello";
}

IOW, the result of your lisp-callable function does not have to be a ResultBuffer, it can be that, or any value you can put into a TypedValue's Value field as well. The runtime looks at the result and converts it to the appropriate LISP result. In the case of System.Boolean, that would be the symbol T for True, or NIL for False.

You cannot return COM objects to VisualLisp using LispFunction, but you write a COM-callable wrapper that can return COM objects or any other ActiveX compatible type, which can be called from LISP using VLAX-* functions.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"Guido Rooms" wrote in message news:5825119@discussion.autodesk.com...
Hi,

I was wondering if it's possible to return a plain nil (as opposed to a list
containing just nil) from a lisp callable function.
The other night I was experimenting a bit and the only thing I could think
of was this

Return New ResultBuffer(New TypedValue(LispDataType.Nil))

I'm also wondering if there's a way to typecast a VB boolean value to
LispDataType.T_atom or LispDataType.Nil
For now I'm doing something like this:

If Condition Ten
SomeTypedValue = New TypedValue(LispDataType.T_atom)
Else
SomeTypedValue = New TypedValue(LispDataType.Nil)
End If

Thanks in advance
and beg pardon if these are stupid questions.
0 Likes
Message 3 of 8

Anonymous
Not applicable
Tony,

On the one hand, thanks for your reply. As usual, I've saved it to my
'Tanzillo' folder.

On the other hand, I find this whole AutoCAD .NET api thing depressing.
Visual Studio's object browser seems to be the only tool I've got to
decipher it. But clearly, that's not enough. Moreover, nobody seems to know
if and when Autodesk is going to descend from heaven to write decent
documentation. Considering the price tag that comes with AutoCAD, I think
this is scandalous. We're paying about the same amount as customers in the
US, except that here the unit is one Euro. The only thing one could do is to
pay even more for an ADN subscription. But they're telling me ADN isn't
something to write home about, either. The apps I'm writing are just in
house stuff, nothing commercial. There's only me and a colleague who
actually use them. So,this gives us the option of dumping the idea of
programming AutoCAD... If I lost some money only, I wouldn't complain so
loud. But here, I'm losing time, which is much worse.

Thanks again for the reply.
Greetings.

Guido Rooms.

"Tony Tanzillo" wrote in message
news:5825108@discussion.autodesk.com...
These aren't stupid questions, if for no other reason because there is
virtually no documentation on any of this.

A method marked with the LispFunction attribute should return a ResultBuffer
only if you are returning a list.

If you are returning an atom, you just return that value directly.

For example, this method will return the symbol T:

[LispFunction("foo")]
public static object Foo( ResultBuffer args )
{
return true;
}

and this will return the integer 99:

[LispFunction("bar")]
public static object Bar( ResultBuffer args )
{
return 99;
}

and this will return the string "Hello":

[LispFunction("baz")]
public static object Baz( ResultBuffer args )
{
return "Hello";
}

IOW, the result of your lisp-callable function does not have to be a
ResultBuffer, it can be that, or any value you can put into a TypedValue's
Value field as well. The runtime looks at the result and converts it to the
appropriate LISP result. In the case of System.Boolean, that would be the
symbol T for True, or NIL for False.

You cannot return COM objects to VisualLisp using LispFunction, but you
write a COM-callable wrapper that can return COM objects or any other
ActiveX compatible type, which can be called from LISP using VLAX-*
functions.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"Guido Rooms" wrote in message news:5825119@discussion.autodesk.com...
Hi,

I was wondering if it's possible to return a plain nil (as opposed to a list
containing just nil) from a lisp callable function.
The other night I was experimenting a bit and the only thing I could think
of was this

Return New ResultBuffer(New TypedValue(LispDataType.Nil))

I'm also wondering if there's a way to typecast a VB boolean value to
LispDataType.T_atom or LispDataType.Nil
For now I'm doing something like this:

If Condition Ten
SomeTypedValue = New TypedValue(LispDataType.T_atom)
Else
SomeTypedValue = New TypedValue(LispDataType.Nil)
End If

Thanks in advance
and beg pardon if these are stupid questions.
0 Likes
Message 4 of 8

Anonymous
Not applicable
Ha! I never knew that! Thanks Tony!
0 Likes
Message 5 of 8

Anonymous
Not applicable
Hello Daniel,

Indeed, you and I and many others in this newsgroup seem to find Tony's
answers very helpful & useful and so we say thank you and thanks again,
which is only natural.

Now, just imagine that for any reason on no reason at all, Tony stops
posting here...

What I mean is this: if AutoDesk is not going to produce decent
documentation soon, or at least inform us when the aforementioned
documentation will be forthcoming, then it would be unwise for those among
us who are not in the know to go on inversting time in this .NET api thing.

Could be that's exactly wat they want. There may be more money in it for
them that way. !?
I think I can smell a rat here...

Kind greetings to you.
Guido Rooms.


wrote in message news:5825190@discussion.autodesk.com...
Ha! I never knew that! Thanks Tony!
0 Likes
Message 6 of 8

Anonymous
Not applicable
The documentation is just shameful, the helloworld example in the documentation throws an exception! I get more info by using reflector. If it weren’t for the good people here and at theswamp.org, willing to share and help others, I would be lost.

Thanks Tony, you rock,
0 Likes
Message 7 of 8

Anonymous
Not applicable
I concur !

//kwb

wrote in message news:5825318@discussion.autodesk.com...
The documentation is just shameful, the helloworld example in the
documentation throws an exception! I get more info by using reflector. If it
weren't for the good people here and at theswamp.org, willing to share and
help others, I would be lost.

Thanks Tony, you rock,
0 Likes
Message 8 of 8

Anonymous
Not applicable

I concut, too.

And I also have to thank you, Tony.

 

I concur
!

//kwb

<Danielm> wrote in message

href="news:5825318@discussion.autodesk.com">
size=2>news:5825318@discussion.autodesk.com

size=2>...
The documentation is just shameful, the helloworld example in the

documentation throws an exception! I get more info by using reflector. If it

weren't for the good people here and at theswamp.org, willing to share and

help others, I would be lost.

Thanks Tony, you
rock,
0 Likes