Re: delete(var) and try-catch

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed, 22 Aug 2007 09:26:41 -0600 (MDT)

Hi Bruce,

You ask some good questions. I'm afraid the procedure below wouldn't
work because of scoping rules. From a test script I wrote, "foo" won't be
recognized outside the procedure, so it won't be possible to delete
it.

If I'm wrong, I will post back here and let you know. The
documentation for scoping seems to indicate that you should be able to
access variables outside of a function.

--Mary

On Tue, 21 Aug 2007, Lunde, Bruce N CIV NAVOCEANO, NP1 wrote:

> Hello,
>
> Is there any way to turn the following into
> a procedure ?
>
> if( isvar("foo") )then
> delete(foo)
> end if
>
>
> Related to this, is there any way to perform
> a "try-catch" statement in order to try executing
> a statement and catching any errors so that the
> script does not exit on a failure ? For example,
>
> begin
> print(1)
> delete(myvar)
> print(2)
> end
>
> will never get to "print(2)" if "myvar" does
> not exist (using delete() as an example of
> something that could fail).
>
> Something like
>
> try:
> delete(myvar)
> catch IERR:
> print("no myvar, error code "+IERR)
> endtry
>
>
> Thanks, Bruce
>
>
> =====
> Bruce Lunde
> Bruce.Lunde_at_navy.mil
> 228-688-5843
> Code NP1
> Naval Oceanographic Office
> Stennis Space Center, MS
> =====
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Aug 22 2007 - 09:26:41 MDT

This archive was generated by hypermail 2.2.0 : Thu Aug 23 2007 - 15:57:17 MDT