%stringize and %endstringize statements (SDL script)
This topic applies to TDK SDL script extensions. For more information, see Overview of SDL script extensions for TDK (SDL script).
SDL Script Extensions for TDK:
%string A = %stringize
int SelectGreater (int A, int B) {
if (A < B) {
A = B;
printf ("A was less than B\n");
}
return A;
}
%endstringize
The %stringize block converts the enclosed text into a string. The example is equivalent to the following:
%string A =
"int SelectGreater (int A, int B) {\n"
" if (A < B) {\n"
" A = B;\n"
" printf (\"A was less than B\\n\");\n"
" }\n"
" return A;\n"
"}\n"
Note the last "}" is followed by a \n. This happens unless %dontlf is specified as follows. %dontlf prevents the last \n to be appended to the translated text:
%string A = %stringize %dontlf
int SelectGreater (int A, int B) {
%endstringize
is equivalent to
%string A = "int SelectGreater (int A, int B) {"
By default, the string is taken without its native indent, that is, the leading blanks common to each line of text are discarded. The optional modifier %keepindent changes the default so that native indent is preserved:
%string A = %stringize %keepindent
int SelectGreater (int A, int B) {
%endstringize
is equivalent to
%string A = " int SelectGreater (int A, int B) {\n"
When both %dontlf and %keepindent are used, they must be specified in that order:
%string A = %stringize %dontlf %keepindent
....
%endstringize