newlisp.dll UTF8 used with purebasic 5.62

Q&A's, tips, howto's
Locked
HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

newlisp.dll UTF8 used with purebasic 5.62

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

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

Re: newlisp.dll UTF8 used with purebasic 5.62

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

gekkonier
Posts: 15
Joined: Fri Jan 26, 2018 7:44 pm

Re: newlisp.dll UTF8 used with purebasic 5.62

Post 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

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

Re: newlisp.dll UTF8 used with purebasic 5.62

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

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

Re: newlisp.dll UTF8 used with purebasic 5.62

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

Locked