Hi everyone,
I’m working with PLCnext and c++, and my program creates a text file when I activate one digital input on PLCnext. I was wondering how can I use a StaticString<80> variable to be part of the text file? Since I was concatenating only pure strings it was working with any problem but when I tried to concatenate a StaticString<80> variable, throws me an error.
Here, I declared my ports on Eclipse in the header file.
image.png
Here, I declared my variables in the cpp program file.
image.png
Here, I concatenated those variables, and my string variable ‘fileName’ throws me an errror.
I tried to convert StaticString<80> variables with some methods but it didn’t work. Can someone please help me with this?
How can I convert a StaticString<80> variable to string?
I posted this on the feedback section, but I made a mistake on my first picture. I redeclared the variables but it’s not working anyway.
Best regards!
Hello Ra,
to your Question:
I tried to convert StaticString <80> variables with some methods but it didn’t work. Can someone please help me with this? How can I convert a StaticString<80> variable to string?
Please try to implement the following code:
Declaration in header file:
StaticString<80> strValue = “”; // String
Implementation in cpp file:
this->strValue = “This is a StaticString with max. 80 char.”;
string strNormValue = this->strValue.ToString().CStr();
I don’t test it, but it should work. If not, please let me know.
Thanks & BR
Eduard
Hi Eduard,
It actually worked!
Thanks & BR
Ra