Purebasic meets newLISP

Started by newdep, July 26, 2004, 10:11:15 AM

Previous topic - Next topic

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/">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

#1
>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

#2
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

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

newdep

#4
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

#5
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

#6
Got it compiled.

Thanks again.
Hans-Peter

newdep

#7
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">http://www.nodep.nl/downloads/newlisp/pbnl.exe
-- (define? (Cornflakes))

HPW

#8
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

#9
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

#10
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

#11
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

#12
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

#13
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

#14
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