PLUS+1 Software > Code sharing

String Concatenate C Code POU

(1/2) > >>


Does anyone have a C Code POU they could share with me that will concatenate one string to another or a POU that does something similar that could help me get started?  Something that would concatenate two UINT8 arrays is probably what it should do.

I could probably do it myself but I'm sure I'd make a few dumb mistakes since I'm relatively new to GUIDE and haven't made a C Code POU yet.


Well, I tried it myself and it works correctly.  I'm not sure I did everything the best way; maybe someone could critique it.  I was stingy with the input string length and I couldn't think of a way of relating the output string length in the code and the length specified in the VAR_OUTPUT section.  I also would've liked to use pointers in the C Code but I couldn't get that to happen with the input type.

See the attachments for images of my Page and C code, and I also attached my SCS file.



A developer gave me this:
"To concatenate two strings natively in GUIDE, the preferred method is to use a standard ST (Structured Text) POU. (See example below)"

Code example in the P1P.

I hope it helps.

This is much better and now I can see how to use other "STRING related PLC functions" in the GUIDE Manual.


This seems to be working great except if I have any other error, I also get this warning:

--- Code: ---*** WARNING 447:1105 *** [PLC2C] PLC Code Compilation Warning {String of default length will be returned,
which may be less than expected length. Save expression into temporary variable to avoid uncertainty.}
Line: [ 1 ] in implementation of StrConcat_Native
--- End code ---

I changed the code to do what the warning recommended, 'Save expression into temporary variable to avoid uncertainty" and that warning doesn't happen anymore.



[0] Message Index

[#] Next page

Go to full version