Help With UDINT To STRING

Hi,

I have the following code that should take a UDINT data and change to a STRING output but I get an error " Subscripted value is neither array nor pointer nor vector" But I have no idea what it means.

{ /* begin of FUNCTION BLOCK: POU_15 */

/* type code here */

UTILS_String_t OututStringObj;
OututStringObj.pcBuffer = &OutputString[0];
OututStringObj.u16BufferSize = 8u;
OututStringObj.u16BufferPos = 0u;

DisplayHourMeter = Input;

/* Convert data to string */
datoul = DisplayHourMeter;
HourMetChar1 = datoul / 100000;
datoul = datoul % 100000;
HourMetChar2 = datoul / 10000;
datoul = datoul % 10000;
HourMetChar3 = datoul / 1000;
datoul = datoul % 1000;
HourMetChar4 = datoul / 100;
datoul = datoul % 100;
HourMetChar5 = datoul / 10;
HourMetChar6 = datoul % 10;

UTILS_String_snprintf(&OututStringObj, "%d%d%d%d%d.%d", HourMetChar1,HourMetChar2,HourMetChar3,
HourMetChar4,HourMetChar5,HourMetChar6);

} /* end of FUNCTION BLOCK: POU_15 */


Last edited on
Hello thebig1,

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

You are missing the function definition. Along with the header files, main and where this function is called from.

As it is I have no idea what "UTILS_String_t" is or where it came from. The same for "OututStringObj", Is this a class or struct? And how is "pcBuffer" defined. The rest of the line is trying to set "pcBuffer" equal to the address of "OutputString[0]", but what is "OutputString"? A string, an array, a vector or something else? The error message that you posted leads me to believe that "OutputString" is not some type of array or anything that could use a subscript.

Next time try to post the actual error message, so there is no question or confusion about the error.

Hope that helps,

Andy
Topic archived. No new replies allowed.