COM in newLISP

Started by codernwo, November 10, 2007, 01:50:09 AM

Previous topic - Next topic

codernwo

Hi,



I have just discovered newLISP and it happens to be my first Lisp. I find it powerful enough to think of adopting it for my scripting needs.



   However iam disappointed that there is no COM support . Since most of my scripting on windows involves automation, i find this a serious handicap.



   Has anyone thought of adapting a library like disphelper for newlisp? I have seen lb_dishelper(for liberty basic) and comlib(for REBOL) which use a dll version of the disphelper library.



   I think this can be done for newlisp also. However my lisp is still at the learning stage to do this.



   Any thoughts on this anyone?



codernwo

Lutz

#1
There shouldn't be a problem to import the relevant DLLs.



newLISP's library interface needs good C-language knowledge to use it, but is also a very tight and fast interface. If you are familiar with C you might want to look at chapter 20 in the "Code Patterns in newLISP" document:



http://newlisp.org/CodePatterns.html#extending">http://newlisp.org/CodePatterns.html#extending  



This file is also linked from here:



http://newlisp.org/index.cgi?Documentation">http://newlisp.org/index.cgi?Documentation



In any case, welcome to newLISP



Lutz

codernwo

#2
Thanks for the tip. I intend to start work on this soon.I Will post any development made.





codernwo

m35

#3
You may be interested in the COM work over at the Autohotkey scripting language:

http://www.autohotkey.com/forum/topic22923.html">http://www.autohotkey.com/forum/topic22923.html

http://www.autohotkey.com/forum/topic21674.html">http://www.autohotkey.com/forum/topic21674.html



I spent a month or so working on COM inclusion in newLISP, but eventually dropped it for the better "http://www.autohotkey.com/forum/topic20765.html">Easycom.dll" program, which was then dropped to develop the "http://www.autohotkey.net/~easycom/">ws4ahk" library. :)



The easiest way to do COM is to use Microsoft Scripting Control (like ws4ahk uses). The next easiest would probably be to make a DLL to do most of the work (like Easycom.dll does). Finally you could just do all the raw COM calls entirely in newLISP (my first efforts).



You're welcome to have the leftover newLISP or Easycom.dll code if you're interested.

SHX

#4
m35
QuoteThe easiest way to do COM is to use Microsoft Scripting Control (like ws4ahk uses).


I would like to understand what you are saying.



Are you saying that currenlty there is a facility within Newlisp to use Microsoft Scripting Control and then you can access com objects via a scripting language?



Steven

m35

#5
SHX



newLISP does not currently have access to the Microsoft Scripting Control. However, by creating a newLISP interface to it (such as "ws4ahk" does for Autohotkey), then yes, you can execute VBScript or JScript code directly in your newLISP code. Thus you can gain easy access to COM.

SHX

#6
QuoteHowever, by creating a newLISP interface to it

m35,



Excuse my ignorance but does that mean that the interface to the Microsoft Scripting Control can be written in Newlisp script by interfacing with the dll or does it mean some sort of external interface in c or something.



Steven

m35

#7
Quote from: "SHX"Excuse my ignorance but does that mean that the interface to the Microsoft Scripting Control can be written in Newlisp script by interfacing with the dll or does it mean some sort of external interface in c or something.


Sorry, I misunderstood what you were asking.



COM can be directly accessed by any language that can do 2 things:

* Import and call DLL functions

* Call functions at arbitrary memory locations



Since newLISP can do these things, it can have direct access to the Microsoft Scripting Control DLL (msscript.ocx), as well as all the other DLLs necessary to interface with COM. It doesn't need any external C or C++ interface.

SHX

#8
Thanks, now I see.



It would be great if someone would develop such a wrapper.

codernwo

#9
Some neat tips and links from m35. Thanks.



     Regarding the approach, though  the C DLL approach is easier for me I would like to build an interface entirely in  newLisp. Hence I  would like to take up m35's offer of the leftover newLisp code and build on it. This will also help me to learn newLisp in a practical way.



  So the next question(to m35) is where do I get this leftover newLisp code?   ;-)

m35

#10
While codernwo gets to mull over my crazy code, I made a quick port of the ws4ahk script to newLISP. It's not as complete, and may even be a little incorrect, but my brief tests seemed to work. Just throwing this out here in case anyone is interested.



http://www.autohotkey.net/~easycom/winscript.lsp">http://www.autohotkey.net/~easycom/winscript.lsp



Edit: Updated url for v0.11

Lutz

#11
Special thanks for documenting this useful module for newLISPdoc.



There is a new special section http://newlisp.org/modules/">http://newlisp.org/modules/ where all commented modules and other source files can be collected.



I started with m35's winscript module and and a link to Dmitry's utilities. If I forgot anything which was published earlier and needs to be included, republish the file here on the board and I can copy it from there.



Lutz



ps: I will upload the updated newlispdoc utility with improved page headers and expanded functionality for index paged later.

cormullion

#12
Hey Lutz - ! Great to see the modules clustering together... But browsing through the documentation for these modules, some of them say:


QuoteTo use this module include the following load statement at the beginning of the program file:

 (load "/usr/share/newlisp/crypto.lsp")


But on my system everything is in "/usr/share/newlisp/modules/:"


newlisp:
guiserver:
allfonts-demo.lsp
animation-demo.lsp
border-layout-demo.lsp
button-demo.lsp
clipboard-demo.lsp
cursor-demo.lsp
drag-demo.lsp
font-demo.lsp
frameless-demo.lsp
html-demo.lsp
image-demo.lsp
mouse-demo.lsp
move-resize-demo.lsp
pinballs-demo.lsp
properties-demo.lsp
rotation-demo.lsp
shapes-demo.lsp
sound-demo.lsp
stroke-demo.lsp
tabs-demo.lsp
textrot-demo.lsp
uppercase.lsp
widgets-demo.lsp
word-count.lsp
guiserver.jar
guiserver.lsp
init.lsp
modules:
cgi.lsp
crypto.lsp
ftp.lsp
gmp.lsp
infix.lsp
mysql.lsp
mysql5.lsp
odbc.lsp
pop3.lsp
postscript.lsp
smtp.lsp
sqlite3.lsp
stat.lsp
unix.lsp
xmlrpc-client.lsp
zlib.lsp
util:
httpd-conf.lsp
link.lsp
newlisp.vim
syntax.cgi


(Sorry for the non-Windows post...)

newdep

#13
Nice module, great work!!
-- (define? (Cornflakes))

m35

#14
Thanks newdep.



I found a memory leak, so I'll upload a new version later.



But I wanted to ask if anyone can think of a better way to do these get-short and get-single (i.e. float) functions. These seem sloppy, but nothing is coming to me.


(define (get-short int-address , s)
    (setq s "  ")
    (cpymem int-address (address s) 2)
    (first (unpack "d" s))
)

(define (get-single int-address , s)
    (setq s "    ")
    (cpymem int-address (address s) 4)
    (first (unpack "f" s))
)