Hi,
This is an extract from the example code I sent you,
this is looking at passing a string that you wish to change the size when its returned.
// Changes the size of a string
int32 DynamicStringResize(LStrHandle in_string, int32 size)
{
MgErr error;
int32 i;
// Strings have the first 32 bits determine how many characters are in the string
error = DSSetHandleSize(in_string, sizeof(int32) + size*sizeof(uChar) );
if (error != mFullErr && error != mZoneErr)
{
(*in_string)->cnt=size;
for (i=0; i
(*in_string)->str[i]=(uChar)(65+i); //65 is decimal for character 'A'
return 0;
}
else return -1;
}
You need to call the function DSSetHandleSize to allocate an area of memory
for your string.
The function passes the size of the string to be returned, but you dont need to do that. you just have to ensure your set the size which is define in the string structure eg (*in_string)->cnt=size, as in the example above. Then copy your string to the structure string. Providing you follow the same procedure it should all work.
Another example, this is passing a cluster of which one of the elements is a string:
// Allocate space for LabVIEW string with 5 characters
DSSetHandleSize(in_cluster->lvString, sizeof(int32) + 5*sizeof(uChar) );
// Set the size paramater of the LV string structure
(*(in_cluster->lvString))->cnt=5;
// Fill the LV string with the string we want in the cluster
strcpy ( (*(in_cluster->lvString))->str, "hello" );
This bit of code allocates enough space to return a string of 5 chars. And the string returned is "hello".
Hope is helps
Regards
Ray Farmer
Regards
Ray Farmer