09-21-2012 11:01 AM - edited 09-21-2012 11:02 AM
Hello,
I need help, because I try to write 2 string in an array of string in opc server, but just the first string is writing in the array.
The function to write the array of string (like the example of LabWindows/CVI about the function DS_SetDataValue) is:
void start_batch(char sqlname[12])
{
char *nomlot[] = {"String Value 1", "String Value 2"};
HRESULT hr = S_OK;
hr = DS_SetDataValue (dsHandle[0][37], CAVT_ARRAY | CAVT_CSTRING, nomlot, sizeof (nomlot) / sizeof (nomlot[0]), 0);
}
The array is empty before to launch the application:
And the array becomes as below in the OPC client:
The second string isn't written correctly.
Someone help me please?
Thank you.
Best Regards.
09-24-2012 06:40 AM
Hi Kalcutt,
I think you inverted the parameter. Try this way:
hr = DS_SetDataValue (dsHandle[0][37], CAVT_CSTRING | CAVT_ARRAY, nomlot, sizeof (nomlot) / sizeof (nomlot[0]), 0);
Regards
Romain DUVAL || RF & Semiconductor Staff System Engineer || CLA || CTA
National Instruments France
09-24-2012 07:18 AM
Hello,
Thank you for your advice, but it doesn't work even like it.
And I have seen in the past, that the help about DataSocket is wrong, because for all communication I can't use CAVT_CSTRING | CAVT_ARRAY but I have to use CAVT_ARRAY| CAVT_CSTRING otherwise it doesn't work.
In the help, the explanations are :
Example of scalar of type double
double value = 5.5;
DS_SetDataValue (dsHandle, CAVT_DOUBLE, &value, 0, 0);
Example of string
char *value = "String Value";
DS_SetDataValue (dsHandle, CAVT_CSTRING, value, 0, 0); Example of 1D array of doubles
double value[] = {4.0, 5.0, 5.5};
DS_SetDataValue (dsHandle, CAVT_DOUBLE | CAVT_ARRAY, value, sizeof (value) / sizeof (value[0]), 0);
Example of 1D array of strings
char *value[] = {"String Value 1", "String Value 2"};
DS_SetDataValue (dsHandle, CAVT_CSTRING | CAVT_ARRAY, value, sizeof (value) / sizeof (value[0]), 0);
But it's wrong.
Bye.