escaping a quotation mark from within an NCL string

From: Jonathan Vigh <vigh_at_nyahnyahspammersnyahnyah>
Date: Wed, 11 Mar 2009 00:31:49 +0000

    Hopefully this is an easy question . . . I'm wondering if it is
possible to escape a quotation mark within a string in NCL, similar to
what is done for the shell in command line options (or calls using
systemfunc) using "\" or single quote marks. The reason I'd like to do
this is that I'm writing NCL code to dynamically generate more NCL code,
and I'd like to be able to put a quotation mark in the resulting string.

Right now, one solution is to add a quotation mark character to the
string every place I want a quotation mark to appear in the resulting
output string, otherwise NCL gets confused and interprets the desired
quotation mark as terminating the current string. A really simple
example is:

  quote = inttochar(34)

  module_contents = " fin = addfile(processed_data_directory +
processed_filelist_at_array(istorm), "+quote+"r"+quote+") ; open input
file" + cr \

which will generate the following line of code in the module:

    fin = addfile(processed_data_directory +
processed_filelist_at_array(istorm), "r") ; open input file

Obviously, this could get really tricky for a complicated expression
with many quotes. So I'm wondering if there is a way to escape the
quotation mark within an NCL string? Enclosing the whole thing in single
quotes doesn't seem to work.


ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Tue Mar 10 2009 - 18:31:49 MDT

This archive was generated by hypermail 2.2.0 : Thu Mar 12 2009 - 14:10:21 MDT