Randy,

I have two string buffers PEFileName and buf. I declared them like this

static
PEFileName : str.strvar ( 250 );
buf : str.strvar ( 250 );

After a call to GetOpenFileName PEFileName contains "c:\RadAsm\.....". I then tried to copy PEFileName to buf.

str.cpy ( PEFileName, buf );

buf now contains "C:\R"

But if I use lstrcpy ( buf, PEFileName ) I have no problems.
Maybe I did something wrong but I think it is worth looking into.
Posted on 2003-03-24 20:59:57 by Odyssey
Keep in mind that the Win32 API calls only return zero-terminated
strings, not HLA strings. This is why the lengths are all messed up
on return.
Most Win32 API functions that return strings also return the string's
length as the function return result, so you can usually do something
like the following:

Win32APIFunc( StringBufferArea);
mov( StringBufferArea, ebx );
mov( eax, (type str.strRec ).length ); //EAX contains function return result

This shoves the length returned by the API function into the HLA string's length field.
If you don't have the length to play with, there are two options: (1) call one of the
HLA "zero-terminated string to HLA string" conversion functions. (2) use the zero-
terminated string functions (e.g., str.zcpy) rather than the HLA string functions.
Cheers,
Randy Hyde
Posted on 2003-03-24 22:48:13 by rhyde
The HLA string ,Null terminated string and win api issue gives me a lot of headaches. Always having to convert between one and the other and not knowing when converting is necessary.

I have never heard of the str.zcpy function. I need to update my reference material. Have you added more Null terminated string functions?
Posted on 2003-03-24 23:02:33 by Odyssey

The HLA string ,Null terminated string and win api issue gives me a lot of headaches. Always having to convert between one and the other and not knowing when converting is necessary.

I have never heard of the str.zcpy function. I need to update my reference material. Have you added more Null terminated string functions?


Somewhere around HLA v1.39 or v1.40 I added several zero-terminated string functions that operate directly on zstrings for people who are interfacing with C code and don't
want to do the conversion(s). See
http://webster.cs.ucr.edu/Page_hla/HLADoc/HTMLDoc/HLAStdlib.html#pgfId-1072050
for more details.
I don't have quite as rich a set of functions as the C Standard Library, but there's quite a few of the C functions present here.

Do keep in mind that zstrings are quite a bit less efficient (speed-wise) than HLA strings if you actually do any manipulation of the strings in your code.
*Someday* I may get around to writing wrapper functions for those Win32 API calls that return string data so that they automatically set the HLA string length upon return.
Cheers,
Randy Hyde
Posted on 2003-03-25 20:48:20 by rhyde