newlisp.dll UTF8 used with purebasic 5.62

Share your advanced PureBasic knowledge/code with the community.
HPW
User
User
Posts: 26
Joined: Tue Apr 29, 2003 6:48 pm
Location: Germany

newlisp.dll UTF8 used with purebasic 5.62

Post by HPW »

Hello,

Today I find a bit time to test a this combination: newlisp.dll UTF8 with purebasic 5.62
Since purebasic is a unicode compiler, it was interesting to use newlisp.dll UTF8.

Importing the dll is simple:

Code: Select all

OpenLibrary(0,"newlisp_utf8.dll")
The call function can look like this:

Code: Select all

sourcestr.s = GetGadgetText(#Gadget_Form1_String3)
*newlispstr = AllocateMemory(StringByteLength(sourcestr) + SizeOf(Character))
PokeS(*newlispstr, sourcestr, Len(sourcestr),#PB_UTF8)
retstr.s = PeekS(CallFunction(0,"newlispEvalStr",*newlispstr),-1,#PB_UTF8)
FreeMemory(*newlispstr)
SetGadgetText(#Gadget_Form1_Editor5, retstr)
At the end you can (not needed, but cleaner)

Code: Select all

CloseLibrary(0)
Regards
Hans-Peter
Hans-Peter
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: newlisp.dll UTF8 used with purebasic 5.62

Post by Kwai chang caine »

Hello HPW :wink:
I have not often heard talking of LISP :oops:

So i have search on the web and found apparently it's a full open source langage like PYTHON, RUBY, etc ...so i believe :oops:
But i don't know the advantage to use it, against PYTHON, RUBY or if it's nearly the same powerfull :|

Your example being not really easy to understand for a beginer, i have found the link of the LISP
http://www.newlisp.org/index.cgi?Home
the link for download the DLL for windows x86 and rename it to "newlisp_utf8.dll"
http://www.newlisp.org/downloads/UTF-8_ ... ewlisp.dll
and a simple addition formula
And apparently..that works :shock:

Code: Select all

OpenLibrary(0,"newlisp_utf8.dll")
sourcestr.s = "(+ 3 2)"
*newlispstr = AllocateMemory(StringByteLength(sourcestr) + SizeOf(Character))
PokeS(*newlispstr, sourcestr, Len(sourcestr),#PB_UTF8)
retstr.s = PeekS(CallFunction(0,"newlispEvalStr",*newlispstr),-1,#PB_UTF8)
FreeMemory(*newlispstr)
Debug retstr
CloseLibrary(0)
Now, perhaps someone can explain what LISP can do, that the over open source langages, cannot :wink:
Thanks a lot for your sharing 8)
ImageThe happiness is a road...
Not a destination
Fred
Administrator
Administrator
Posts: 16684
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: newlisp.dll UTF8 used with purebasic 5.62

Post by Fred »

You could use the 'p-utf8' pseudotype and a function prototype to ease the call (CallFunction() is now discouraged to use in PureBasic due to various reasons)

code (not tested):

Code: Select all

; Define your function pointer, with auto utf8 conversion (and cleaning)
Prototype newlispEvalStrProto(input.p-utf8)

newlispEvalStr.newlispEvalStrProto = GetFunction(0, "newlispEvalStr")

retstr.s = PeekS(newlispEvalStr(GetGadgetText(#Gadget_Form1_String3)),-1,#PB_UTF8)

SetGadgetText(#Gadget_Form1_Editor5, retstr)
HPW
User
User
Posts: 26
Joined: Tue Apr 29, 2003 6:48 pm
Location: Germany

Re: newlisp.dll UTF8 used with purebasic 5.62

Post by HPW »

Hello Kwai chang caine,
Now, perhaps someone can explain what LISP can do, that the over open source langages, cannot
First newlisp is another open source language.
Since you have found the Homepage yourself, you may further read some arguments for using it:
http://www.newlisp.org/index.cgi?FAQ

For me the most importend arguments are:
Small size and fast loading.
Easy embeddable.
For an Interpreter very fast execution.
Good documentation: http://www.newlisp.org/downloads/manual_frame.html

Credo: Use the right tool to get the Job done.

Regards
Hans-Peter
HPW
User
User
Posts: 26
Joined: Tue Apr 29, 2003 6:48 pm
Location: Germany

Re: newlisp.dll UTF8 used with purebasic 5.62

Post by HPW »

Hello Fred,

Thanks for the code comment and tip.
I will try it out today.

Very appreciated!

Regards
Hans-Peter
Hans-Peter
HPW
User
User
Posts: 26
Joined: Tue Apr 29, 2003 6:48 pm
Location: Germany

Re: newlisp.dll UTF8 used with purebasic 5.62

Post by HPW »

Hello Fred,

It works like a charm.

Now a one liner in my Event Loop select:

Code: Select all

SetGadgetText(#Gadget_Form1_Editor5, PeekS(newlispEvalStr(GetGadgetText(#Gadget_Form1_String3)),-1,#PB_UTF8))
Much cleaner and readable.

Regards
Hans-Peter
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: newlisp.dll UTF8 used with purebasic 5.62

Post by Kwai chang caine »

Thanks HPW for your explanation 8)

I love all the library in DLL, EXE, etc who can be used with PB 8)
A day, INFRATEC create like you, a thread for embeded PYTHON with his DLL, and this subject interested me a lot 8)

I'm always happy to see, the power of PB can be again more big, with the help of all this nice and powerfull programs and library :D
Unfortunately, the OOP is everywhere and numerous of this big jewel is inaccessible :|
A simple example, i need SELENIUM for remote FF, and the only one solution for use it with PB, it's embeded PYTHON for that PYTHON use SELENIUM at his turn, surely because SELENIUM is OOP, and only OOP langage can use it :|
The other way is using server JAVA, but JAVA is not always installing on all machine :|

So thanks to you, i know a new langage can be used hand in hand with PB, thanks again for all :wink:
ImageThe happiness is a road...
Not a destination
HPW
User
User
Posts: 26
Joined: Tue Apr 29, 2003 6:48 pm
Location: Germany

Re: newlisp.dll UTF8 used with purebasic 5.62

Post by HPW »

Hello,

Here the current Version with callback-support:

viewtopic.php?f=13&t=71552

Regards
Hans-Peter
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: newlisp.dll UTF8 used with purebasic 5.62

Post by Kwai chang caine »

Thanks a lot 8)
ImageThe happiness is a road...
Not a destination
Post Reply