Re: systemfunc question

From: Mark Snyder <msnyder_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 01 2010 - 11:03:32 MDT

Mary,

Thanks, I just tested it out and it works great.

Mark

On Jun 1, 2010, at 7:36 AM, Mary Haley wrote:

> The problem is that you are imbedding double quotes within double quotes. NCL doesn't allow you to do this.
>
> If you need a double quote to be part of your string, then you need to create a variable that contains the double quote, and construct the string.
>
> For example (untested)
>
> dq = str_get_dq()
> cmd = "grep " + dq + "parameter(iproj=" + dq + " domain.param | sed " + dq + "s/parameter(iproj='\(\w\+\)'.*/\1/" + dq
> proj = systemfunc(proj)
>
>
> --Mary
>
> On May 31, 2010, at 4:32 PM, Mark Snyder wrote:
>
>> Hi,
>>
>> I'm attempting to read a string from a text file using systemfunc:
>>
>> begin
>>
>> proj = systemfunc("grep "parameter(iproj=" domain.param | sed "s/parameter(iproj='\(\w\+\)'.*/\1/"")
>> print(proj)
>>
>> end
>>
>> And it seems that NCL is balking at the ( between parameter and iproj (note the dashes are shorter in the email than what appears in the terminal, so the ^ points to the end of the line). I was looking at the documentation for a way to escape the ( but didn't find anything.
>>
>> Copyright (C) 1995-2009 - All Rights Reserved
>> University Corporation for Atmospheric Research
>> NCAR Command Language Version 5.1.1
>> The use of this software is governed by a License Agreement.
>> See http://www.ncl.ucar.edu/ for more details.
>> fatal:syntax error: line 6 in file read_domain.param.ncl before or near parameter
>> proj = systemfunc("grep "parameter
>> ---------------------------------^
>>
>> fatal:Syntax Error in block, block not executed
>> fatal:error at line 9 in file read_domain.param.ncl
>>
>> Thanks,
>> Mark
>>
>>
>> --
>> Mark A. Snyder, PhD | Assistant Project Earth Scientist
>> Climate Change and Impacts Laboratory
>> Dept. of Earth and Planetary Sciences
>> University of California, Santa Cruz
>> (W) 831-459-3504 | msnyder@pmc.ucsc.edu
>> http://es.ucsc.edu/~msnyder
>> --
>> <domain.param>_______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
Received on Tue Jun 1 11:03:48 2010

This archive was generated by hypermail 2.1.8 : Mon Jun 07 2010 - 16:48:44 MDT