newLISP Fan Club

Forum => Anything else we might add? => Topic started by: newdep on July 26, 2004, 10:11:15 AM

Title: Purebasic meets newLISP
Post by: newdep on July 26, 2004, 10:11:15 AM
As a followup from Hans-Peters example on Powerbasic ill post here the

Purebasic version. The binary compiled version you can find on my website

(http://www.nodep.nl/newlisp/)  windows is ready, linux in the make.



below the code..

Enjoy...



;

; Purebasic 3.91 meets newLISP 8.0.15 by Norman.

; (this is the windows exmaple, ill bake a linux too)



; as purebasic lacks some good essentials like

; logic programming grammer and a good network library

; it has i.e. a very nice advantage like GUI development

; for windows and linux. Purebasic is not freeware.

;

; below you see how purebasic GUI incorporates with

; the language power of newlisp.

;

; the example below inserts all new messages from the

; udp-threadened listener into a GUI text API.

;

; Purebasic has the abbility of including Library calls

; into its own environment, so i had to import the newlisp

; newlispEvalStr into PureBasic to make a litte more basic-like.

; Still it is also possible to do direct Library calls to the

; newlisp.dll. Not included here.

;

; make sure you run this program with the newlisp.dll in the

; same directory or place newlisp.dll (8.0.15) somewhere in your

; windows system directory.

;

;



; create a socket thread in Purebasic

; calling the (net-receive-udp) from newLISP.



Procedure listen()

Repeat

Delay(10); cpu cooler :-)

gotdata = newlispEvalStr_( "(set 'nlgotdata (net-receive-udp 54054 512))" )

 If gotdata > 0

  AddGadgetItem(1,0,PeekS(newlispEvalStr_( "(nth 1 nlgotdata)" )) + " -> " + PeekS(newlispEvalStr_( "(nth 0 nlgotdata)")))

 EndIf

Until quit = 1    

EndProcedure





If OpenWindow(0,100,100,400,200,#PB_Window_SystemMenu,"PureBasic meets newLISP")

  If CreateGadgetList(WindowID(0))

    EditorGadget(1,10, 10, 380, 180)

    AddGadgetItem(1,0,"Now Listening at 127.0.0.1 on port 54054")

    AddGadgetItem(1,0,"Try send a (net-send-udp address port text)")

  EndIf  



  ; launch the thread

  tid = CreateThread(@listen(),100)

 

Repeat

    Delay(10) ; another cpu cooler...

Until WaitWindowEvent()=#PB_Event_CloseWindow



EndIf



; kill the thread

KillThread(tid)



End
Title:
Post by: HPW on July 26, 2004, 10:58:17 AM
>Purebasic is not freeware.



It is not expensive and it has a lifetime-license.

So thanks for the example.

One more GUI-alternative for the newLISP-community!
Title:
Post by: HPW on July 26, 2004, 11:25:55 AM
Just test a neobook based UdpSender with your PB-UdpListener.

Works fine.

With its 17 KB filesize it take 3.5 MB memory.

A neobook Listener take about 6 MB (because the runtime)

A pure newlisp.exe with linked LSP take about 1.3 MB memory.



Now it would be interesting to see a demo with a text-entry widget

where I can type a lisp expression and then I press a 'eval' button

and the result is shown somewhere. A mini-IDE in purebasic.
Title:
Post by: HPW on July 26, 2004, 11:38:05 AM
Quote
; Purebasic has the abbility of including Library calls

; into its own environment, so i had to import the newlisp

; newlispEvalStr into PureBasic to make a litte more basic-like.


Where/how do you do this?



I have Purebasic 3.91 for Windows installed.
Title:
Post by: newdep on July 26, 2004, 11:47:16 AM
Its done with the dll importer from the commercial version where it has

the SDK tools.. the readme included describes the way of building it..

its easy...
Title:
Post by: newdep on July 26, 2004, 11:51:09 AM
Btw... its easy to build an Eval from newlisp in Purebasic ;-)



As newlisp has this GREAT was useing newlispEvalStr..



I could build one...ill try tomorrow...
Title:
Post by: HPW on July 26, 2004, 01:27:03 PM
Got it compiled.

Thanks again.
Title:
Post by: newdep on July 27, 2004, 08:01:52 AM
Oke i build a very very very very simple evaluation example

with a Windows GUI in Purebasic.



Actualy it lacts a lot ;-)

above all the GUI will hang  untill a "blocking IO command" return a value. This could actualy be fixed with a Thread in the tool, but its just an example..



http://www.nodep.nl/downloads/newlisp/pbnl.exe
Title:
Post by: HPW on July 27, 2004, 12:23:57 PM
Beside that it is a nice demo, it shares the same problem with the powerbasic demo. Since it is compiled, no runtime-GUI generation with dynamic callbacks is possible, as it is possible with TK. There is the real power, when the GUI is flexibel as newLISP is.
Title:
Post by: newdep on July 27, 2004, 02:43:19 PM
Oo your right there, i dont deny this is to static.

Its was just an example. Still i like the more flexible way

of TK and GTK-server myself too :-)
Title:
Post by: HPW on July 27, 2004, 11:28:42 PM
Since I was not familar with your GTK-server, I just give it a try and installed it.



I ran your demo-scripts and it works as expected.

I have a question about your GTK-server and the GTK-enviroment.

Is there a way to bundle the enviroment and the server to a self-contained windows executable? (TK has a TclApp/TclDevKit for building Starpacks/Starlibs).

Or how would I install it on a fresh user-mashine?

(3 Installer one after another?)
Title:
Post by: pjot on July 28, 2004, 05:45:31 AM
My GTK-server for Windows currently needs 2 installers: the GTK environment and the GTK-server itself. The installer for the GTK-environment was created by somebody else, I just asked for permission to host the installer on my site. (I have to ask for his installscripts and combine that with mine to create one big installer containing everything.)



But the GTK-environment can also be used for other applications using GTK, like the Gimp, Ethereal, and so on. Therefore it seems logical to me that it has it's own installer.



With the Windows-port it is not possible to create a stand-alone binary which contains all the GTK stuff by itself (statically linked). This is a limitation of the Win32 version of GTK. In Unix however this is possible; see my Makefile.static in the sourcepackage for details.



Concluded: a fresh user-machine needs only 2 installers - the GTK-environment for GTK2 (recommended) and the GTK-server for GTK2.
Title:
Post by: HPW on July 28, 2004, 06:00:55 AM
With the third installer I mean my own files with the newLISP-logic.

So anyway this is not so elegant as the possibilitys with TK.

But may be the GTK guys get there in the future.

We (the newLISP users) have the choice.
Title:
Post by: newdep on July 28, 2004, 07:51:52 AM
Hello Hans-Peter,



I'm helping with the Grk-Server but Pjot is the person your seeking for ;-)

He is 1000% into Gtk-Server ;-)



Norman.
Title:
Post by: HPW on July 28, 2004, 08:22:56 AM
Hello Norman,



two competent guys from the netherlands here on the forum. ;-)

Always a chance to speak to the wrong one.



Grk-Server?

Another newLISP-platform? Miss I something? ;-)
Title:
Post by: pjot on July 28, 2004, 08:26:32 AM
Hi Hans-Peter,



Well, I do not know if your application works in Linux too, but then you'ld only have 2 installers: the GTK-server and your newLisp application. On every Linux distribution GTK already is installed by default.



Greetz,

Peter
Title:
Post by: newdep on July 28, 2004, 08:55:29 AM
Typo.. its Gtk-server... Im too bussy today ;-)
Title:
Post by: nigelbrown on July 28, 2004, 01:11:49 PM
Re: Since it is compiled, no runtime-GUI generation with dynamic callbacks is possible,



I've not seen the code but a compiled program can still be variable in how it builds a gui

if the calling method is dynamic and it doesn't just use a resource file type approach?



Nigel
Title:
Post by: HPW on July 28, 2004, 01:21:15 PM
Nigel,



of cource you are right. You can have a compiled code which generates dynamic GUI's.



But the most flexible approach is possible with interpreted newLISP generating interpreted TK-GUI-code.
Title:
Post by: nigelbrown on July 28, 2004, 01:48:12 PM
What about NewLisp dynamically creating html pages/forms it then serves out with httpd?

Or dynamically making php/being called by php (served out by another server)?



Nigel
Title:
Post by: HPW on July 28, 2004, 01:59:52 PM
OK, OK



simple formula:



newLISP = endless possibiltys



;-)





"the greatest single programming language ever designed"



- Alan Kay, on Lisp (from Graham's site)
Title:
Post by: pjot on January 03, 2005, 03:01:56 AM
Hi HPW,



In this thread we were discussing the amount of installers with GTK-server:
Quote
With the third installer I mean my own files with the newLISP-logic.

So anyway this is not so elegant as the possibilitys with TK.

But may be the GTK guys get there in the future.

We (the newLISP users) have the choice.

Accidentaly I have prepared an example ZIP package, which includes eveything you need to run a newLisp program. It is the UDP demo program converted to an EXE, also the GTK-server and all necessary DLL's are in the ZIP:



http://www.gtk-server.org/UDP-Chat.zip



Just unzip and run the VBS starter "chat.vbs" (no virus in there).



It's just an example on how a newLisp program could be distributed without the tedious procedure of going through all kinds of installers... The ZIP file also could have been a self-extractable ZIP, or an NSIS installer, or whatever.



Peter
Title:
Post by: HPW on January 03, 2005, 07:43:34 AM
Hi Peter,



Thanks for the sample distribution.

The newLISP developer can now choose between the options.