What’s the one thing you need to know when using a literal string in the source code of any programming language? How to embed a quote character.
It can be maddening to locate this tiny piece of information (as it was for me with VFP). Therefore this blog post is appropriately titled with the keywords: FoxPro, literal, string, embed, quote, etc. so that hopefully we’ll save somebody 30 minutes in the future…
Here’s the answer:
LOCAL lcHtmlBody;
* Single quotes and double quotes can be embedded in a string by delimiting the string with square brackets:
lcHtmlBody = [<html><body>Embedded Image:<br /><img src="something/dudeAbc.gif"/></body></html>]
* Single quotes can be embedded with double quotes:
lcHtmlBody = "<html><body>Embedded Image:<br /><img src='something/dudeAbc.gif'/></body></html>"
* Double quotes can be embedded with single quotes:
lcHtmlBody = '<html><body>Embedded Image:<br /><img src="something/dudeAbc.gif"/></body></html>'
* You cannot use two quotes in a row (as in VB6) or a backslash (as in C++ or C#) to embed quotes.