[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ROUTINE_NAMES and other magic




One thing that ROUTINE_NAMES() (**note) cannot do is *add* variables
to another level.  If the variable exists, then you can muck as much
as you want with it, but if it doesn't exist, sorry.


Oh, another funny thing.  Try this recursive procedure:

  PRO DEEPSTOP, level
  if level EQ 2 then stop
  deepstop, level + 1
  END

and then run it with

  deepstop, 1

% Stop encountered:  DEEPSTOP            2 /dev/tty
IDL> help
% At  DEEPSTOP            2 /dev/tty
%     DEEPSTOP            3 /dev/tty
%     $MAIN$                 
LEVEL           INT       =        2
Compiled Procedures:
    $MAIN$  DEEPSTOP
Compiled Functions:

Okay, this is fine.  We've stopped two recursive levels down.  But
then if we try to set a variable like this:

IDL> a = 1

a = 1
     ^
% Unable to add local variable to recursively active program unit: DEEPSTOP

Freaky!  It's probably not meaningful in most situations; only when
you have recursive procedures which define dynamic variables via
EXECUTE().  Just thought it was cute.

Craig


**note - ROUTINE_NAMES() is the recently discussed magical function
which allows one to manipulate variables at other call levels


-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------