newLISP Fan Club

Forum => Anything else we might add? => Topic started by: starseed on July 29, 2006, 03:12:48 PM

Title: callbacks into newlisp?
Post by: starseed on July 29, 2006, 03:12:48 PM
Hi,



I'm toying around with newlisp, and am trying to use IUP [1] for gui creation.

I have been able to show something (hooray! ;-), and the interesting part will be to add callbacks to buttons, etc.



How does newlisp-tk handle this? I guess there's a function added to the tk side of things?



I have skimmed through the sources, but haven't been able to find the right place to look at. I'm not too fluent in C, and not at all in tk, this may be part of it ...





If you some pointers to enlighten me, it will be highly appreciated.





Kind regards,



Ingo





[1] http://www.tecgraf.puc-rio.br/iup/
Title:
Post by: HPW on July 29, 2006, 11:23:46 PM
QuoteHow does newlisp-tk handle this? I guess there's a function added to the tk side of things?


Get the source and take a look at ....newlispnewlisp-8.9.1newlisp-tknewlisp-tk.tcl. There is a '(tk   ....)' which is used to call TCL/TK from newLISP. Communication is via the TCP/IP protocol. You can also take a look at the demo-sources.



But you may also consider to use newLISP.dll, which is easily embedded in different enviroments. One advantage is that you only have one visible main-process.
Title:
Post by: Lutz on July 30, 2006, 12:42:10 AM
Look also at this program:



http://newlisp.org/index.cgi?page=Tk_and_newLISP



with this and the newLISP executable alone (no newlisp-tk required) you can run the demos included. It makes you understand how newLISP and Tcl/Tk communicate via 2 channels.



Lutz
Title:
Post by: starseed on August 01, 2006, 01:11:01 PM
Well, I would really like to use the dll directly, but then I need away to call back into newlisp.



I've tried to use a changed dll, but:

- host newlisp has access to the dll newlisp env, and dll newlisp C-callbacks

- iup has access to the dll environment (newlispEvalStr), and the added C-callbacks

- BUT the dll newlisp does not have access to it's own C-Functions, which I need ...



I feel like biting into my own tail ... ;-)
Title:
Post by: Lutz on August 01, 2006, 02:40:24 PM
Use two pipes to communicate with another application, one for newLISP to listen, the other one for the other process to listen. This way you can simulate callbacks.



The newLISP-tk application works in a similar way with 2 TCP/IP channels and http://www.gtk-server.org/ does both TCP/IP and pipes.



There are some examples for this in the description for the function 'process' in the manual.



Lutz
Title:
Post by: Lutz on August 01, 2006, 02:45:42 PM
... and perhaps you could use signal handlers in newLISP as a call back mechanism.



Lutz