Re: a script with a variable name to load

From: Saji Hameed <saji.nh_at_nyahnyahspammersnyahnyah>
Date: Fri Apr 01 2011 - 16:35:38 MDT

Another strategy would be to set it as an environment variable from
your calling script..

eg.

export MyRootDir="/tmp/plots"

>From NCL, you retrieve it with
load getenv(MyRootDir)+"/a.ncl"

saji

On Sat, Apr 2, 2011 at 7:22 AM, mark collier <Mark.Collier@csiro.au> wrote:
> Hi Dennis,
> no I think loadscript will not allow "a" to be seen by the rest of the
> script (ie "a" will not have global extent).
> Regards,
>
> On 02/04/2011, at 2:07 AM, Dennis Shea wrote:
>
>> Is "loadscript" what you need?
>>
>> http://www.ncl.ucar.edu/Document/Functions/Built-in/loadscript.shtml
>>
>> On 4/1/11 12:18 AM, mark collier wrote:
>>> Hi,
>>> often I run code from an external NCL script.
>>>
>>> For example, the external script a.ncl might contain
>>>
>>> a=1.0
>>>
>>> and so in my parent script I can simply go
>>>
>>> begin
>>> load "a.ncl"
>>> print(a)
>>> end
>>>
>>> and so the variable a is effectively global in extent, and it often
>>> helps to keep the parent script compact and the code more clumped by
>>> relevance.
>>>
>>> However, I can't load a script in a variable location, eg
>>>
>>> idir="/home"
>>> load idir+"/a.ncl"
>>> print(a)
>>>
>>> or variations, I get a message like "input in flex scanner failed".
>>> It
>>> works if I put the full path in, however, the aim is to have a
>>> variable path. I think I understand why it is failing, but are
>>> looking
>>> for a work around?
>>>
>>> Regards,
>>> Mark.
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Apr 1 16:35:45 2011

This archive was generated by hypermail 2.1.8 : Tue Apr 05 2011 - 09:01:21 MDT