Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - DavMin

#1
newLISP in the real world / ODBC on Access db
December 16, 2011, 08:57:52 AM
(set 'sourcedir (append (env "USERPROFILE") "\Desktop\Newlisp Access"))
(load (append sourcedir "\odbc.lsp"))

(if (not (ODBC:connect (append sourcedir "\fake.accdb") "" "")) (println "not connected..")
(println "connected.."))


Output:


"C:\Documents and Settings\dm\Desktop\Newlisp Access" (lambda ()   (if (not (ODBC:connect "test-db" "" ""))    (exit))   (println "connected ...")   (ODBC:query "insert into fruits values ('apples', 11)")   (ODBC:query "insert into fruits values ('oranges', 22)")   (ODBC:query "insert into fruits values ('bananas', 33)")   (println "inserted 3 records")   (ODBC:query "select * from fruits")   (println "performed a query")   (println (ODBC:num-cols) " columns in result set")   (println "fetching rows ...")   (while (set 'row (ODBC:fetch-row))    (set 'row (map trim row))    (println row))   (println)   (ODBC:query "delete from fruits")   (println "rows deleted: " (ODBC:affected-rows))   (println "nclosing database")   (ODBC:close-db)) Could not connect not connected.. "not connected.."

What have I done wrong? Thanks.
#2
Very cool. Thank you!
#3
I see I need to link it into an exe, then I can pass cmd line args. Thanks.
#4
I'm running a single program in newlisp and want to pass an argument:



newlisp dl.lsp '123456'



I doesn't seem like newlisp accepts openargs. Did I miss something?



I suppose I could write it to a text file and have the program read the text file to retrieve the info :(
#5
I saved the Html web page, opened it in Ms Word then saved it as a Pdf.



I could mail it to you if you don't have Word.
#6
newLISP in the real world / Re: Socket Callback into Vb
December 13, 2011, 12:19:29 PM
A different option would be to run newlisp.exe with the socket code loaded and use SendMessage API from within the newlisp program to notify my main program when data is complete.
#7
newLISP in the real world / Re: Socket Callback into Vb
December 13, 2011, 10:32:50 AM
Ok, wait. I think I see what's going on.



The example you are giving is how to register a callback in the dll from lisp.



What I am wanting to do is register a callback in the dll from Vba/Vb6.



So there is a hook in the dll to register a callback but there seems to be no way to callback into Vb because it's using a different namespace for it's functions.



However, I have seen this done before in a com/dll. I think it's possible, I'm just not as knowledgeable as you folks here.



Thanks
#8
newLISP in the real world / Re: Socket Callback into Vb
December 13, 2011, 10:20:32 AM
Yes, I think that's what I need and I saw this code in the manual earlier.. but I still don't understand how I'd hook this up in my code.



I have:



Public Declare Function NewlispEval Lib "NewLisp" Alias "newlispEvalStr" (ByVal LExpr As String) As Long



so I would also declare:



Public Declare Function NewlispCallback Lib "NewLisp" Alias "newlispCallback" (ByVal Callback As String) As Long



?



Then in my code I would write:



Sub Form_Open()

NewlispEval "(load callme.lsp)"

NewlispCallback "CallbackHandler"

End Sub



Sub CallbackHandler(DataReturned as String)

Text1 = DataReturned

End Sub



?



I think I'm missing something. What is initially returned by NewlispCallback ? Probably not a long, maybe a boolean for success/fail? Then what is returned by the callback itself? A string? A pointer to a string?



This is the code I got from the Excel example:


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


I mention this because there is some post processing of the returned pointer. Is the value returned by the callback a pointer as well?



Thanks!
#9
newLISP in the real world / Re: Socket Callback into Vb
December 13, 2011, 08:40:35 AM
I think you are missing my point. I was using the Webbrowser.DownloadComplete event as example of an asynchronous event.



I can load and call the newlisp.dll all I want and it works and I am happy with that. What I was wondering was if it's possible to assign newlisp.dll a callback:



Sub Form_Open()

Newlisp "(load 'socket.lsp')"

Newlisp.Callback("Socket_DataComplete")

End Sub



Sub Socket_DataComplete(IncomingData as String)

Me.Text1 = IncomingData

End Sub



Where Newlisp.Callback is assigned the function or subroutine to call when socket.lsp has completed processing of a new message.
#10
newLISP in the real world / Re: Socket Callback into Vb
December 12, 2011, 09:34:39 PM
Quote from: "sunmountain"To get you right:

you want to handle all network stuff with newlisp and have it inform the VB app an changed data ?

--

That said: If you set up newlisp to wait for events, your form will do nothing - except you

do that in a thread - which complicates the thing even more.


Example: I use an Internet Explorer control and load a web page

webbrowser0.navigate "asd.com"



The form doesn't block or wait in a loop, it responds to commands.

After the web page is downloaded a webbrowser0.downloadcomplete event fires and I can write code to respond.



I guess I'm just asking if you can register callbacks to respond through the DLL and allow the DLL to operate asynchronously.



Using .net just complicates things even more for me. My only other idea would be to use the odbc connection to write messages to a shared table and use a timer to periodically query.
#11
newLISP in the real world / Re: Socket Callback into Vb
December 12, 2011, 01:49:52 PM
Oh, ok.



In Vb, when I add a reference to a DLL I can see the interfaces in the object viewer. If I add newlisp.dll there is one function: NewlispEval.



Some DLL have events that can be hooked within the editor. A fictional socket interface would have a DataReceived event:


Private Sub Socket1_DataReceived()
Me.Text1 = Socket1.IncomingData
End Sub


I've read that newlisp handles a set number of callbacks. I imagined that each callback could be set through the NewlispEval function then have generic event handles for those callbacks:


Private Sub NewLisp_Callback1()
Me.Text1 = NewLispEval("(net-receive socket 'buf 1)")
End Sub


 Sorry, not very good at sockets or newlisp yet. I've played around with sockets in vb months ago and found it terribly difficult. There was a 'DataReceived' event but what I actually wanted was an asynchronous "Data Complete" so I could let the form work as usual and show asynchronous updates as they come.



Thanks
#12
newLISP in the real world / Re: Socket Callback into Vb
December 12, 2011, 10:34:35 AM
I should mention this is Vba/Vb6, not .net



Thanks.
#13
newLISP in the real world / Socket Callback into Vb
December 12, 2011, 09:59:00 AM
I'd like to use net-listen to signal a data received event into my Vb application. I'm using the newlisp.dll and didn't want to poll the port. Is this possible?



Thanks.
#14
newLISP in the real world / Re: crypto.lsp sha256
December 11, 2011, 12:10:56 AM
Aha. I see thank you for the help!
#15
Maybe you can recreate for HTML5 Canvas?



http://www.newlisp.org/code/modules/canvas.lsp.html">//http://www.newlisp.org/code/modules/canvas.lsp.html



http://easeljs.com/">//http://easeljs.com/



http://paperjs.org/">//http://paperjs.org/



http://box2d-js.sourceforge.net/">//http://box2d-js.sourceforge.net/



Though it's 3d, this might inspire:

http://mrdoob.com/129/Voxels">//http://mrdoob.com/129/Voxels

(click the top left frame that says Voxels)