11-08-2011 03:43 PM
I need to display a long text string (multi line) in a pop up message.
If I do this with one very long string in the .c file it works (I do have several \n within the string so that it looks okay in the pop up.
However if I try to spread the text string over several lines CVI complains, how do I get around this, I don't want to use an excessive number of columns.
This is what it does not like:
case EVENT_RIGHT_CLICK:
MessagePopup ("Run Test Jig Interface Test Help", "
This test verifies that this program can communicate with
the ATJ hardware.\n\n This program requests the hardware and
firmware revison of the ATJ and then records the results in this section as well as in the test report");
break;
Thanks
Solved! Go to Solution.
11-08-2011 05:17 PM - edited 11-08-2011 05:18 PM
Just write it like this:
case EVENT_RIGHT_CLICK:
MessagePopup ("Run Test Jig Interface Test Help",
"This test verifies that this program can communicate with "
"the ATJ hardware.\n\n This program requests the hardware and "
"firmware revison of the ATJ and then records the results in this section as well as in the test report");
break;
If you need to put the string literal in a #define you'd need to write it like this:
#define kMultiLineString "Here is some text " \
"that spans across " \
"multiple lines."
11-08-2011 05:20 PM
You can split the text into multiple lines using line continuation character "\", this way:
MessagePopup ("Run Test Jig Interface Test Help", "This test verifies that this program can communicate with " \ "the ATJ hardware.\n\n This program requests the hardware and " \ "firmware revison of the ATJ and then records the results in this " \ "section as well as in the test report");
11-09-2011 10:03 AM
Thanks,
That works, I don't recall having to use the / in C before (I must be getting old?)
11-09-2011 12:06 PM
As I posted in my reply, you don't actually have to use \ character, unless you're using a #define (in that case it's required so that the preprocessor knows the #define spans multiple lines). CVI (and every other C environment I'm aware of) will concatenate multiple strings into a single one as long as they are all wrapped in quotes and there's nothing but whitespace in between them.
11-14-2011 09:14 AM
An answer can also be found by searching the forum: http://forums.ni.com/t5/LabWindows-CVI/Splitting-a-string-over-several-lines-in-a-c-file/td-p/405928