PDA

View Full Version : Invoking dll through Kyoto Common Lisp


Rupin
01-24-2006, 11:40 PM
Hi,

This is with regards to customizing CoCreate's products using the lisp that is shipped alongwith CoCreate's products. I have following queries :

1. Is there any way to invoke a dll (windows library) through the lisp

2. Can we execute system commands through the lisp?(e.g calling an executable from the lisp code, or running some script/batch file...)

Any help is appreciated.
Rupin

clausb
01-25-2006, 08:55 AM
To find out how to run external commands from OSDM, check out the Integration Kit documentation, particularly the "Filing and Operating System" section. Several of my demo examples at http://www.clausbrod.de/Osdm/OsdmMacros also cover the subject of interfacing with external components.

OSDM can also interface via other options, such as DDE and COM/.NET. DDE support is part of the Integration Kit (IKIT); refer to the IKIT docs for programming information and to http://www.clausbrod.de/Osdm/MacroHelloExcel for a simple example. For details on the .NET API, please contact your CoCreate representative or CoCreate support.

Our Lisp implementation can also call directly into C++ DLLs. This, however, is an advanced technique which is not covered in the IKIT, so I'll have to refer you to CoCreate support again if you require this level of detail.

BTW, in many cases where users try to call external tools to get things done, it turns out eventually that they could just as well use internal functionality, which is usually a more robust and faster solution.

So there are quite a few options available. If you could give me an idea of what kinds of tasks you need to accomplish, I could probably recommend a "path of least resistance" to you.

Hope this helps,

Claus

Lim Chee Beng
01-25-2006, 08:19 PM
... refer to the IKIT docs for programming information and to http://www.clausbrod.de/Osdm/MacroHelloExcel for a simple example...

I went thru by issueing the commands according to the example.

(setf dde (oli:sd-dde-initiate "Excel" "System"))
(display dde) ; returned #S(DDE-HANDLE DDE-HANDLE-PTR 117440897)

(setf cell (oli:sd-dde-request dde "R1C1"))
(display cell) ; returned ERROR

(oli:sd-dde-execute dde "[Formula(\"=TODAY()\", \"R1C1\")]")
; cell A1 = 1/26/2006

What is the possible root cause of sd-dde-request error, while other commands seem to be working fine? :confused:

clausb
01-25-2006, 09:58 PM
Thanks for spotting this, and sorry for this; I goofed up. To read data from a specific worksheet, we need to explicitly connect to it, rather than to Excel "in general":


(setf dde (oli:sd-dde-initiate "Excel" "[Book1]Sheet1"))
(setf cell (oli:sd-dde-request dde "R1C1"))


I'm assuming that you're running an English version of Excel which happens to call its default workbook "Book1" and its default worksheet "Sheet1".

Sorry for the sloppy editing in the original article - I guess it was a little too late last night :-) http://www.clausbrod.de/Osdm/MacroHelloExcel has of course been updated accordingly.

Claus

Rupin
01-27-2006, 12:24 AM
Hi Claus,

Thanks for all the useful information. I'm specifically looking at invoking some DLL/exe functions through SDLisp. Further to your information, I have the following doubts:

1.
OSDM can also interface via other options, such as DDE and COM/.NET. DDE support is part of the Integration Kit (IKIT); refer to the IKIT docs for programming information and to http://www.clausbrod.de/Osdm/MacroHelloExcel for a simple example. For details on the .NET API, please contact your CoCreate representative or CoCreate support.

There are a few commands in the Integration Kit (sd-activate-addin (file:///E:/Program%20Files/CoCreate/OSD_Modeling_2005/help/osdm/Common/documentation/integration_kit/reference/dotnetapi.html#sd-activate-addin); sd-deactivate-addin (file:///E:/Program%20Files/CoCreate/OSD_Modeling_2005/help/osdm/Common/documentation/integration_kit/reference/dotnetapi.html#sd-deactivate-addin); sd-call-addin-command (file:///E:/Program%20Files/CoCreate/OSD_Modeling_2005/help/osdm/Common/documentation/integration_kit/reference/dotnetapi.html#sd-call-addin-command)) which can invoke an addin. Can we use this to call our custom DLL/exe? Do you have some examples regarding their usage?

Also since you are redirecting me to CoCreate Support, I suspect that .NET API comes in a separate license, is that true?

2.
Our Lisp implementation can also call directly into C++ DLLs. This, however, is an advanced technique which is not covered in the IKIT, so I'll have to refer you to CoCreate support again if you require this level of detail.

Can I get hold of this technique by refering to some standard lisp articles available online etc. or is this something specific to CoCreate (and maybe requires some license etc.)? If it comes with the standard license, then do you have some examples?

Thanks.
Rupin

clausb
01-27-2006, 12:40 AM
Rupin,

sd-activate-addin and friends are part of the .NET API. Hence, to use them, you have to get our .NET API SDK, which has all the documentation and examples you'll probably need. CoCreate support is probably your best contact to get this ball rolling.

The same applies for the ability to directly call C++ code. It's possible, but this is low-level functionality and has the potential to compromise the stability of the product if used inappropriately. Also, we cannot guarantee cross-version compatibility. For these reasons, we hand this out to selected partners only, so as far as I know, there is no public information on this out there. Again, this is probably something you should discuss with our support folks - just tell them I sent you .-).

I can of course help to establish the contact for you - just send me your email address (preferrably in a private message) and maybe a few high-level facts about your project. Thanks!

Claus