I code in VBA MS Access. I see great scripts and have loaded newLISP.
I have some VBA code to run newLISP in MS Access database. I have successfully called some basic functions but would like to know how to call a script as seen in http://www.newlisp.org/syntax.cgi?code/twitter.txt
from MS Access.
Here is some code I have so far in a public module:
Option Compare Database
Public Declare Function dllNewlispEval Lib "NewLisp" Alias "newlispEvalStr" (ByVal LExpr As String) As Long
Private Declare Function LoadLibraryA Lib "kernel32" (ByVal s As String) As Long
Private Declare Sub FreeLibrary Lib "kernel32" (ByVal h As Long)
Declare Function lstrLen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Long) As Long
Declare Function lstrCpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As Long) As Long
Dim NewlispHandle As Long
Sub Auto_Open()
LoadNewLISP
End Sub
Public Sub LoadNewLISP()
Dim mylib As String
Dim hinst As Long
Dim LibPath As String
mylib = "C:\Program Files\newlisp\newlisp.dll"
NewlispHandle = LoadLibraryA(mylib)
If NewlispHandle = 0 Then
MsgBox "Can not find C:\Program Files\newlisp\newlisp.dll on this machine."
End If
End Sub
Function NewLisp(LispExpression As String) As Variant
Dim Result As String
Dim ResHandle As Long
Dim ResultCode As Long
ResHandle = dllNewlispEval(LispExpression)
Result = Space$(lstrLen(ByVal ResHandle))
lstrCpy ByVal Result, ByVal ResHandle
NewLisp = Result
End Function
Public Sub Auto_close()
UnloadNewLISP
End Sub
Sub UnloadNewLISP()
FreeLibrary NewlispHandle
End Sub
Public Function CreateLispScript(strUser As String, pw As String) As Variant
Dim strScript As String
strScript = "(+ 8 3)"
CreateLispScript = NewLisp(strScript)
End Function
Private Sub Command0_Click()
Dim str As Variant
Call LoadNewLISP
MsgBox CreateLispScript("TwitterName", "TwitterPassword")
Call Auto_close
End Sub
Bob Heifler
How to Call scripts
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
This looks like a newLISP expression adding 8 and 3. If it works, and you can somehow, somewhere, see the answer, then you know how to evaluate a newLISP expression! :)Code: Select all
strScript = "(+ 8 3)"
Another newLISP expression you can evaluate is:
Code: Select all
(load "script.lsp")
If you can't see the answer of a newLISP expression, or if I've gone completely off the rails, then perhaps someone with more (any) experience of VBA and Windows can help. A quick search proposes http://www.alh.net/newlisp/phpbb/viewtopic.php?t=809 and http://www.newlisp.org/code/VBA.zip for starters...
To execute another program script and capture the output.
-- xytroxon
Code: Select all
; Note: use {"..\.."} string form for windows path names
; newlisp program (or any windows program with stdout)
(set 'program_path {"c:\program files\newlisp\newlisp.exe"})
; local copy of newlisp script
(set 'script_path {"d:\newlisp\twitter\twitter.nl"})
; add any script options, etc. here
(set 'options "")
; join command list, execute and capture results
(set 'results (exec (join (list program_path script_path options) " ")))
; process program output lines or errors
(println results)
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976
-- Let's Talk Lisp (c) 1976