nested subroutines and scope [message #28994] |
Thu, 24 January 2002 14:56  |
Christopher W. O'Dell
Messages: 20 Registered: February 2001
|
Junior Member |
|
|
This is a two-part question from an IDL newbie.
1) Is it possible to nest procedures or functions in IDL?
2) If the answer to (1) is yes, is there anyway to give certain
variables global scope within the primary procedure/function,
so they can be "seen" by all the nested procedures/functions
within the main function?
I used to do this all the time in pascal. Some pseudo-code might be
as follows:
function mainfunc, x, a1
function subfunc, y
return, a1 * y^2
end ; subfunc
return, subfunc(x) * subfunc(x^2)
end ; mainfunc
If you think this is terrible programming practice (which it probably
is), can anyone suggest a better way, without having to pass
all the global variables as parameters?
Thanks,
Chris O'Dell
|
|
|
Re: nested subroutines and scope [message #29050 is a reply to message #28994] |
Tue, 29 January 2002 05:46  |
Alex Schuster
Messages: 124 Registered: February 1997
|
Senior Member |
|
|
Chris O'Dell wrote:
> 1) Is it possible to nest procedures or functions in IDL?
No.
> If you think this is terrible programming practice (which it probably
> is), can anyone suggest a better way, without having to pass
> all the global variables as parameters?
Oh, I always liked pascal's ability to nest procedures and functions.
For IDL, if there are many parameters, I would put them together into a
structure, so you need only pass this single variable then.
Alex
--
Alex Schuster Wonko@planet-interkom.de
alex@pet.mpin-koeln.mpg.de
|
|
|