max strings

BlitzMax Forums/BlitzMax Programming/max strings

Kanati(Posted 2006) [#1]
ok... I give up. How are strings handled in max? I'm trying to pass and return strings from a dll and all I'm getting is garbage. I've tried passing by reference to the dll, just the string itself, a memory pointer to the string (varptr)... No joy in sending a string to the dll. All I get is a three character string like "PyZ" or something similar with high ascii. In RECIEVING a string from the dll I've tried sending it back as unicode, a pointer to the string, the string itself, null terminated, etc etc etc... All I get back is garbage.

What's going on?


Dreamora(Posted 2006) [#2]
If you want to use them with a DLL (created in C) you must convert them to CStrings using the .toCString() method.

To get it using extern, you must attache $z as returntype (or type declaration for variables)


Kanati(Posted 2006) [#3]
I keep hearing this $z thing and don't see it anywhere in the sparse and relatively useless docs. And since the search function of the site is equally useless.........

I will try the tocstring() method though. Thanks.


Dreamora(Posted 2006) [#4]
$z is a type specifier, but while $ declares a blitz max string, $z declares a C string. This is needed to communicate with most DLLs where you get a string or need to send a cstring.

But you are right with the search functionality and the docs ... hope at least the later will improve over time. The blitzwiki is a good point to start normally, its worlds above the documentation for this kind of "find it out yourself" stuff.


tonyg(Posted 2006) [#5]
and This


Perturbatio(Posted 2006) [#6]
you might want to read this: http://www.blitzbasic.com/Community/posts.php?topic=51481

there are parts mentioning issues with CStrings and automatic garbage collection.