Purebasic meets newLISP

For the Compleat Fan
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Purebasic meets newLISP

Post by newdep »

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
-- (define? (Cornflakes))

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

>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!
Hans-Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

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.
Hans-Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

; 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.
Hans-Peter

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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...
-- (define? (Cornflakes))

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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...
-- (define? (Cornflakes))

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Got it compiled.
Thanks again.
Hans-Peter

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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
-- (define? (Cornflakes))

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

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.
Hans-Peter

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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 :-)
-- (define? (Cornflakes))

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

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?)
Hans-Peter

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

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.

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

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.
Hans-Peter

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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.
-- (define? (Cornflakes))

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

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? ;-)
Hans-Peter

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

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

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Typo.. its Gtk-server... Im too bussy today ;-)
-- (define? (Cornflakes))

nigelbrown
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Post by nigelbrown »

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

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

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.
Hans-Peter

nigelbrown
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Post by nigelbrown »

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

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

OK, OK

simple formula:

newLISP = endless possibiltys

;-)


"the greatest single programming language ever designed"

- Alan Kay, on Lisp (from Graham's site)
Hans-Peter

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Hi HPW,

In this thread we were discussing the amount of installers with GTK-server:
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

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Hi Peter,

Thanks for the sample distribution.
The newLISP developer can now choose between the options.
Hans-Peter

Locked