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
************************************************

 채택된 답변

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")

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품

릴리스

R2006a

Community Treasure Hunt

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

Start Hunting!

Translated by