Hello,
It's been a while since using this language, so I apologize if this is a silly question, but I can't find immediately available information regarding this.
I'm calling a DLL from pure basic. In this instance, I need to use char* as parameters and sometimes as the return value of procedures as well. Should I use .s for this or something else?
Is this legal or do alternative methods need to be used?
In conclusion: what is pb's direct equivalent of c's char* when calling functions from a c dll?
Thanks,
Rory Michie.
equivalent of c strings in pure basic
-
rory-games
- User

- Posts: 39
- Joined: Sun Feb 02, 2020 9:14 am
- Contact:
Re: equivalent of c strings in pure basic
if you import a function from a lib that want's a string parameter and it doesn't work as expected you will generally want to use p-utf8 or p-Ascii. The pseudo types convert to or from PB's UCS2 format
Code: Select all
ImportC "some.lib"
some_function(inputStr.p-utf8,*outPut.p-utf8)
Endimport
-
rory-games
- User

- Posts: 39
- Joined: Sun Feb 02, 2020 9:14 am
- Contact:
Re: equivalent of c strings in pure basic
Hello,
Thanks for the response, this is what I was looking for!
Well, really there is only one more piece I think: how does one convert a pointer at a p-ascii back into a regular string?
Thanks,
Rory Michie.
Thanks for the response, this is what I was looking for!
Well, really there is only one more piece I think: how does one convert a pointer at a p-ascii back into a regular string?
Thanks,
Rory Michie.
Re: equivalent of c strings in pure basic
if the return type is a string then you need to use peeks(*ptr,-1,#PB_UTF8)
and if it's a parameter use *ptr.p-utf8
and if it's a parameter use *ptr.p-utf8
-
rory-games
- User

- Posts: 39
- Joined: Sun Feb 02, 2020 9:14 am
- Contact:
Re: equivalent of c strings in pure basic
Thanks very much again! I see how this works now.
