ProcedureDLL.s just return 1º char of string

Just starting out? Need help? Post your questions and find answers here.
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 637
Joined: Fri Dec 04, 2015 9:26 pm

ProcedureDLL.s just return 1º char of string

Post by skinkairewalker »

Good night people !
I'm creating "shared libraries" for some ready-made engines (GameMaker Studio2 & AppGameKit), both support external libraries ...

Here is an example of a library I am doing:

Code: Select all


DeclareDLL.s SC_Init()

ProcedureDLL.s DLL_Init(Param1.i,Param2.i)
  MessageRequester(PeekS(Param1,-1,#PB_UTF8),PeekS(Param2,-1,#PB_UTF8))
  ProcedureReturn "HelloWorld"
EndProcedure 
I tested this same library on both engines, and it worked ....

to receive strings inside the engines to PurebasicDLL I should use the command: PeekS (PARAM_NAME, -1, # PB_UTF8) ...
but when I need to "return" strings to these two engines, only the first character is sent ...

follow the screenshots

http://prntscr.com/ly4rry
http://prntscr.com/ly4s5c

Is there any way to resolve this in code or is this internal problem in DLL processing of engines?
User avatar
skywalk
Addict
Addict
Posts: 4003
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: ProcedureDLL.s just return 1º char of string

Post by skywalk »

PureBasic strings are unicode, [H][0][e][0][l][0][l][0][o][0], etc.
Your receiving app is probably expecting Ascii, and terminates on the [0] byte.
Try returning a pointer to a Global memory buffer holding an Ascii string.

*b = Ascii("Hello")
ProcedureReturn *b
Remember to FreeMemory *b at end of its use.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 637
Joined: Fri Dec 04, 2015 9:26 pm

Re: ProcedureDLL.s just return 1º char of string

Post by skinkairewalker »

skywalk wrote:PureBasic strings are unicode, [H][0][e][0][l][0][l][0][o][0], etc.
Your receiving app is probably expecting Ascii, and terminates on the [0] byte.
Try returning a pointer to a Global memory buffer holding an Ascii string.

*b = Ascii("Hello")
ProcedureReturn *b
Remember to FreeMemory *b at end of its use.
Works Fine !!! Thanks you SkyWalk <3
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: ProcedureDLL.s just return 1º char of string

Post by #NULL »

Make sure you know what the string format actually is. Receiving utf-8 and returning ascii seems unlikely to me. Try passing and returning special characters like € to see which works.
Post Reply