Why am I unable to insert new line/tabs in code using TLC string?

I am writing a TLC file to inline an s-function when generating code. In the TLC file, I do a lot of string parsing to generate desirable code for the s-function. While doing so, I am unable to insert newlines and tabs in the generated code in a controlled manner.
The TLC file consists of the following code:
%assign output2_if_else_string = "Start_String : \t"
%assign output2_if_else_string = FEVAL ("strcat", output2_if_else_string, "My name is")
%assign output2_if_else_string = FEVAL ("strcat", output2_if_else_string, "\n")
%assign output2_if_else_string = FEVAL ("strcat", output2_if_else_string, "Anuj Gupta")
I expect the output in my generated c code to contain the following strings:
************************************************
Start_String:My name is
Anuj Gupta
************************************************
Instead the output appears as follows:
************************************************
Start_String :My name isAnuj Gupta
************************************************

 Accepted Answer

This behavior is due to TLC string parsing in Simulink 6.4 (Release R2006a).
To work around the issue in this specific example, append /t and /n characters at the beginning of strings when using strcat.
For example, the string parsing code in the user defined TLC file is:
%assign output2_if_else_string = "Start_String : "
%assign output2_if_else_string = FEVAL ("strcat", output2_if_else_string, "\tMy name is")
%assign output2_if_else_string = FEVAL ("strcat", output2_if_else_string,
"\nAnuj Gupta")

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Release

R2006a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!