Page 1 of 1

newlisp.dll UTF8 used with purebasic 5.62

Posted: Sun Oct 07, 2018 12:41 pm
by HPW
Hello,

Today I find a bit time to test a new combination: newlisp.dll UTF8 with purebasic 5.62
Since latest purebasic versions are unicode compiler, it was interesting to use newlisp.dll UTF8 there.

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

Re: newlisp.dll UTF8 used with purebasic 5.62

Posted: Mon Oct 08, 2018 4:03 pm
by HPW
Hello,

After a advice from Fred(Author of purebasic) I now here an improved code:

Init:

Code: Select all

  OpenLibrary(0,"newlisp_utf8.dll")
; Define your function pointer, with auto utf8 conversion (and cleaning)
  Prototype newlispEvalStrProto(input.p-utf8)
  newlispEvalStr.newlispEvalStrProto = GetFunction(0, "newlispEvalStr")
Call in the main Event Loop in my GUI:

Code: Select all

SetGadgetText(#Gadget_Form1_Editor5, PeekS(newlispEvalStr(GetGadgetText(#Gadget_Form1_String3)),-1,#PB_UTF8))
At the end you can (not needed, but cleaner)

Code: Select all

 CloseLibrary(0)
Regards

Re: newlisp.dll UTF8 used with purebasic 5.62

Posted: Tue Oct 09, 2018 3:25 pm
by gekkonier
Hi HPW,
thank you for your example, I will try it later and give you feedback since I use Purebasic too (I'm not that active there, but who knows, thats's something interesting here!)

Gruß, Gregor

Re: newlisp.dll UTF8 used with purebasic 5.62

Posted: Sun Oct 14, 2018 12:45 pm
by HPW
Hello,

With the help of various purebasic fellows from the purebasic community,
I managed to get callbacks to work from newlisp-dll.

Here is a complete purebasic source with the newlisp utf8 dll (32 bit):
http://www.hpwsoft.de/anmeldung/html1/n ... isp_PB.zip

Screenshot:
Image

By the way: One of the reasons why purebasic is a good companion to newlisp is the size of the final exe which is here 49 KB.
For 64 bit purebasic user the 64 bit Dll must be downloaded from newlisp.org.

Regards
Hans-Peter

Re: newlisp.dll UTF8 used with purebasic 5.62

Posted: Wed Oct 17, 2018 4:55 pm
by HPW
Hello,

Updated the demo with 2 more callbacks with Integer and Double parameters.

Again here is the complete purebasic source with the newlisp utf8 dll (32 bit):
This time also the compiled demo with 52224 Bytes.

http://www.hpwsoft.de/anmeldung/html1/n ... isp_PB.zip

Regards