comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: accesing variables defined in a higher program level
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: accesing variables defined in a higher program level [message #33949 is a reply to message #33947] Thu, 06 February 2003 08:52 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Isa Usman (eepisu@bath.ac.uk) writes:

> I am trying to get a function to use variable values that are defined in a
> higher level procedure. Since COMMON blocks can't be used in functions is
> there a way round this? here is an example of what i am trying to do;
>
> Pro high_level
> x=1
> y=1
> z=1
>
> I=integrate('f_x',z)
> end
>
> function integrate,z
> ........
> ........
> call function f_x
> i=........
> return,i
> end
>
> function f_x, z
> w=x+y+z
> return, w
> end

What makes you think COMMON blocks can't be used in functions?
They can be used in functions, procedures, main-level programs,
and--in fact--anywhere in IDL.

Rearranging your code the way it will eventually be in a file
(if you want it to work, that is), why not something like this:

function f_x, z
COMMON data, x, y
w=x+y+z
return, w
end

function integrate, f_x, z
value = call_function(f_x, z)
print, value
return,value
end


Pro high_level
COMMON data, x, y
x=1
y=1
z=1
I=integrate('f_x', z)
end


--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: accesing variables defined in a higher program level
Next Topic: Postscript output mods

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 18 13:49:29 PDT 2025

Total time taken to generate the page: 2.07960 seconds