newlisp.dll UTF8 used with purebasic 5.62

Started by HPW, October 07, 2018, 05:41:28 AM

Previous topic - Next topic

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:

OpenLibrary(0,"newlisp_utf8.dll")

The call function can look like this:

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)

CloseLibrary(0)

Regards
Hans-Peter

HPW

#1
Hello,



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



Init:

 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:

SetGadgetText(#Gadget_Form1_Editor5, PeekS(newlispEvalStr(GetGadgetText(#Gadget_Form1_String3)),-1,#PB_UTF8))


At the end you can (not needed, but cleaner)

CloseLibrary(0)


Regards
Hans-Peter

gekkonier

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

#3
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/newLISP/hpwNewLisp_PB.zip">//http://www.hpwsoft.de/anmeldung/html1/newLISP/hpwNewLisp_PB.zip



Screenshot:

http://www.hpwsoft.de/anmeldung/html1/newLISP/hpwNewLisp_PB.png">



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

#4
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/newLISP/hpwNewLisp_PB.zip">http://www.hpwsoft.de/anmeldung/html1/n ... isp_PB.zip">http://www.hpwsoft.de/anmeldung/html1/newLISP/hpwNewLisp_PB.zip



Regards
Hans-Peter