LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi line string in pop up causes Missing " error

Solved!
Go to solution

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

0 Kudos
Message 1 of 6
(3,257 Views)

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

Kevin B.
0 Kudos
Message 2 of 6
(3,252 Views)
Solution
Accepted by topic author slow-poke

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

 

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 3 of 6
(3,250 Views)

Thanks,

 

That works, I don't recall having to use the / in C before (I must be getting old?)

0 Kudos
Message 4 of 6
(3,235 Views)

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.

Kevin B.
0 Kudos
Message 5 of 6
(3,225 Views)
0 Kudos
Message 6 of 6
(3,211 Views)