Re: about local variable in defined function and procedure

From: Carl Schreck <cjschrec_at_nyahnyahspammersnyahnyah>
Date: Mon Mar 17 2014 - 06:52:31 MDT

This is something that still puzzles me too. I'm having trouble coming up
with an example where a variable doesn't act as local. Consider the very
simple example below, with no locals defined.

--
procedure dummy()
begin
  print( "Procedure: " + isvar("x") )
  x = 1
end; dummy
begin; main
  dummy()
  print( "Main: " + isvar("x") )
  x = 5
  print(x)
  dummy()
  print(x)
end; main
--
All of the isvar's return false, and dummy doesn't change the value of x in
main. So what is the non-local behavior?
    Carl
On Mon, Mar 17, 2014 at 2:10 AM, Jatin Kala <jatin.kala.jk@gmail.com> wrote:
>
> This is explained here:
> http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclStatements.shtml
> Search for: "The local statement and function and procedure scope"
>
> Those functions which do not have local variables declared, are probably
> for the few functions which do Not define anything new within the function,
> i.e., there is No "x=" within the function (hopefully).
>
>
>
>
>
>
> On 17/03/14 4:51 PM, wen wrote:
>
> Hi ncl-users and Dennis,
>     I recently define ncl-fuction and procedure by myself to faciliate my
> processing. I don't think I am familar with the local variable. I find that
> some functions and procedures pre-defined in "contributed.ncl" and others
> do not have local variable, but some do. I am wandering when the function
> or procedure should have local variable. Could you give me some examples to
> show the necessary to define local variable in a function or procedure.
> Thank you!
>
>
>
>
> --
> Best regards
> Guanhuan Wen
>
>
> _______________________________________________
> 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
>
>
-- 
 <http://www.cicsnc.org/>
 <http://www.facebook.com/cicsnc>
*Carl J. Schreck III, PhD*
*Research Associate*
Cooperative Institute for Climate and Satellites NC <http://cicsnc.org/>
North Carolina State University <http://ncsu.edu/>
NOAA's National Climatic Data Center <http://ncdc.noaa.gov/>
151 Patton Ave, Asheville, NC 28801
e: cjschrec@ncsu.edu
o: +1 828 257 3140
CycloneCenter.org: Help analyze tropical cyclones<http://www.cyclonecenter.org/>
monitor.cicsnc.org/mjo: See recent MJO
diagnostics<http://monitor.cicsnc.org/mjo/>


_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Mon Mar 17 06:53:25 2014

This archive was generated by hypermail 2.1.8 : Fri Mar 21 2014 - 15:49:21 MDT