Windows - How do I call a prewritten script?

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
heifler
Posts: 3
Joined: Sun Aug 09, 2009 8:55 pm

Windows - How do I call a prewritten script?

Post by heifler »

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

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Have you tried:

Open Command Prompt, and type:

Code: Select all

newlisp "script"
where script is the name of the script.

Locked