Sophie

Sophie

distrib > Mageia > 5 > i586 > by-pkgid > 37ce2601040f8edc2329d4714238376a > files > 831

eso-midas-doc-13SEPpl1.2-3.mga5.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.1p1 release (March 2nd, 1998)
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Local Keywords</TITLE>
<META NAME="description" CONTENT="Local Keywords">
<META NAME="keywords" CONTENT="vol1">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="vol1.css">
<LINK REL="next" HREF="node43.html">
<LINK REL="previous" HREF="node41.html">
<LINK REL="up" HREF="node38.html">
<LINK REL="next" HREF="node43.html">
</HEAD>
<BODY >
<!--Navigation Panel-->
<A NAME="tex2html1013"
 HREF="node43.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
 SRC="icons.gif/next_motif.gif"></A> 
<A NAME="tex2html1009"
 HREF="node38.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
 SRC="icons.gif/up_motif.gif"></A> 
<A NAME="tex2html1003"
 HREF="node41.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
 SRC="icons.gif/previous_motif.gif"></A> 
<A NAME="tex2html1011"
 HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
 SRC="icons.gif/contents_motif.gif"></A> 
<A NAME="tex2html1012"
 HREF="node216.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
 SRC="icons.gif/index_motif.gif"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1014"
 HREF="node43.html">Conditional Statements, Branching</A>
<B> Up:</B> <A NAME="tex2html1010"
 HREF="node38.html">MIDAS Command Language</A>
<B> Previous:</B> <A NAME="tex2html1004"
 HREF="node41.html">DO Loops</A>
<BR>
<BR>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION00664000000000000000">&#160;</A><A NAME="2156">&#160;</A>
<BR>
Local Keywords
</H2> 

<P>
Because keywords are implemented as a global data structure, different MIDAS
procedures can access the same keyword. This useful feature can cause problems,
however, if these keywords just serve as local, temporary variables like the
<TT>DO</TT> variables. Consider the procedures below:<BLOCKQUOTE>
<TT>!+ <BR>
  ! Example 11, MIDAS procedure exa11.prg <BR>
  !+ <BR>
WRITE/KEYWORD N/I/1/1 0
<BR>
DO N = 1 10 <BR>
     @@ test <BR>
ENDDO</TT>
<TT>!+ <BR>
  ! MIDAS procedure test.prg <BR>
  !+ <BR>
WRITE/KEYWORD N/I/1/1 0
<BR>
DO N = 1 12 <BR>
WRITE/KEYWORD INPUTI/I/12/1 </TT><IMG
 WIDTH="17" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img150.gif"
 ALT="$\{$"><TT>N</TT><IMG
 WIDTH="16" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img151.gif"
 ALT="$\}$"><TT> <BR>
ENDDO</TT></BLOCKQUOTE>Executing <TT>@@ exa11</TT> will give some unexpected results, since both 
procedures access the same integer keyword N as a common variable.
<BR>
<BR>
Therefore, procedures should use <I>local</I> keywords for DO loops <A NAME="2164">&#160;</A>and internal
working storage. Local keywords are defined inside a MIDAS procedure via the
command <TT>DEFINE/LOCAL</TT>. 
They are only known inside the procedure where they are defined (if the
<TT>lower_levels_flag</TT> is set, they are also defined
in all procedures called from this procedure).
Local keywords <A NAME="2167">&#160;</A>may have the same name as an existing global keyword (except the
system keyword names as stored in <TT>MID_MONIT:syskeys.dat</TT>) or local
keyword of any other procedure, since local keywords are searched
before the global ones.
The above example will work, if modified as follows: <BLOCKQUOTE>
<TT>!+ <BR>
  ! Example 12, MIDAS procedure exa12.prg <BR>
  !+ <BR>
DEFINE/LOCAL N/I/1/1 0 <BR>
DO N = 1 10 <BR>
      @@ test <BR>
ENDDO <BR></TT>
<TT>!+ <BR>
  ! MIDAS procedure test.prg <BR>
  !+ <BR>
DEFINE/LOCAL N/I/1/1 0 <BR>
DO N = 1 12 <BR>
WRITE/KEYWORD INPUTI/I/12/1 </TT><IMG
 WIDTH="17" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img152.gif"
 ALT="$\{$"><TT>N</TT><IMG
 WIDTH="16" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img153.gif"
 ALT="$\}$"><TT> <BR>
ENDDO</TT></BLOCKQUOTE>Local keywords are deleted when returning to the next higher level
at the end of a procedure.<BLOCKQUOTE>
<DIV ALIGN="CENTER">
<B>Note</DIV>
<I>Always provide all initial values to a keyword. For example,
<BR>
<TT>define/local lola/r/1/6 0</TT>
usually works as intended, i.e. all elements of keyword <TT>lola</TT> are filled
   with 0, but depending upon the computer and operating system the contents
   of lola(2,...,6) may be unpredictable. So, use
<BR>
<TT>define/local lola/r/1/6 0 all</TT>
   in order to fill all elements of keyword <TT>lola</TT> with 0.</I></B></BLOCKQUOTE><HR>
<!--Navigation Panel-->
<A NAME="tex2html1013"
 HREF="node43.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
 SRC="icons.gif/next_motif.gif"></A> 
<A NAME="tex2html1009"
 HREF="node38.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
 SRC="icons.gif/up_motif.gif"></A> 
<A NAME="tex2html1003"
 HREF="node41.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
 SRC="icons.gif/previous_motif.gif"></A> 
<A NAME="tex2html1011"
 HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
 SRC="icons.gif/contents_motif.gif"></A> 
<A NAME="tex2html1012"
 HREF="node216.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
 SRC="icons.gif/index_motif.gif"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1014"
 HREF="node43.html">Conditional Statements, Branching</A>
<B> Up:</B> <A NAME="tex2html1010"
 HREF="node38.html">MIDAS Command Language</A>
<B> Previous:</B> <A NAME="tex2html1004"
 HREF="node41.html">DO Loops</A>
<!--End of Navigation Panel-->
<ADDRESS>
<I>Petra Nass</I>
<BR><I>1999-06-09</I>
</ADDRESS>
</BODY>
</HTML>