You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have read/write access to a string variable. It's a VT_BSTR.
Reading works fine, I have issues with writing.
First question is: how do I know how many charachters (or bytes) I'm allowed to write, if I didn't get any specs in advance?
Second: How do I make use of all the space I have available?
I ask this because when the string holds, e.g., 10 wchars, I can only write 10 or less.
Using Matrikon OPC I can write all the characters number the PLC developer told me.
My code so far:
std::wstring str(L"The string I want to write");
OPCItemData data;
var.pItem->readSync(data, OPC_DS_DEVICE);
wcscpy_s(data.vDataValue.bstrVal, 64, str.c_str()); // I know I have 64 wchars available
var.pItem->writeSync(data.vDataValue);
The above code works well only if the string already holds more than str.length(), otherwise the string gets truncated (and I fear I might be overwriting memory areas somewhere).
Any help is appreciated.
The text was updated successfully, but these errors were encountered:
Hi everybody,
I have read/write access to a string variable. It's a VT_BSTR.
Reading works fine, I have issues with writing.
First question is: how do I know how many charachters (or bytes) I'm allowed to write, if I didn't get any specs in advance?
Second: How do I make use of all the space I have available?
I ask this because when the string holds, e.g., 10 wchars, I can only write 10 or less.
Using Matrikon OPC I can write all the characters number the PLC developer told me.
My code so far:
"var" is a struct I created:
The above code works well only if the string already holds more than str.length(), otherwise the string gets truncated (and I fear I might be overwriting memory areas somewhere).
Any help is appreciated.
The text was updated successfully, but these errors were encountered: