How to Concatenate Strings to create large string which contains"" inside in object script
Hi Developers,
I need to construct a string as xml which consists of "" in it. As example below
set teststr ="<book id="bk105"><author type="old">Corets, Eva</author><title>The Sundered Grail</title><genre>Fantasy</genre></book>"
giving error in the area where " in middle of the string (highlighted in bold)
Could anybody suggest to me, how to construct a static string in object scripts with " in it?
Product version: Caché 2017.1
Hi
you can take any text editor and replace " with ""_"
Example:
"<book id="""_"bk105"""_"><author type="""_"old"""_">Corets, Eva</author><title>The Sundered Grail</title><genre>Fantasy</genre></book>"
Thanks, Prashanth, It is working fine.
To use a " character within an ObjectScript string literal, double it:
set teststr ="<book id=""bk105""><author type=""old"">Corets, Eva</author><title>The Sundered Grail</title><genre>Fantasy</genre></book>"
Hi Sreevani
In ObjectScript you can include a double-quote character inside a quoted string by doubling it up.
set teststr ="<book id=""bk105""><author type=""old"">Corets, Eva</author><title>The Sundered Grail</title><genre>Fantasy</genre></book>"
Since in this example, your string clearly contains html you might find that using single-quotes inside your string would be cleaner and easier to read, making it more maintainable:
set teststr ="<book id='bk105'><author type='old'>Corets, Eva</author><title>The Sundered Grail</title><genre>Fantasy</genre></book>"
George