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

Home » Public Forums » archive » Hide functions from other procedures
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: Hide functions from other procedures [message #65418 is a reply to message #65322] Fri, 27 February 2009 12:47 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
fugu wrote:
> I have two procedures, and in both .pro files, I define slightly
> different functions with the same name. I would like to make sure,
> that only the procedure in the same .pro file can see 'it's own'
> function, but no other procedure. The reason is, that I often define a
> plot function first (which I call my_plot), which gets than called by
> the actual procedure several times, to plot on screen and to ps etc.

IDL has a global namespace for routines. There is no way to ensure that
only the procedure in the same .pro file can see 'it's own' function
except by carefully managing manual re-compiles of the routines (as
successive compiles bump old routines of the same name out of memory).

> I can off course, give the functions different names, but there are
> good reasons for calling it the same (mainly because I later know the
> function call my_plot without having to look it up etc.)
>
> As an example:
>
> I have two files, called test1.pro and test2.pro, which hold the
> procedures (not surprisingly) test1 and test2.
>
> test1.pro looks like this
>
> HEADER
> FUNCTION my_plot
> ...
> END
>
> PRO TEST1
> ...
> calls my_plot
> END
>
>
> and test2 looks exactly the same, but the function my_plot in test2 is
> different from the function my_plot in test1. Now I hoped, that
> compiling and running test2 would know nothing about the my_plot
> function in test1 which I compiled before. But that does not seem to
> be the case.

So starting from a fresh IDL session, compiling TEST1, then compiling
TEST2, and then calling MY_PLOT results in TEST1's MY_PLOT being called?
I don't see how that's possible. Be careful with compile order: it
happens only the first time you use a function. So calling TEST2, then
TEST1, and then TEST2 again would cause a problem (TEST2 would be
calling TEST1's MY_PLOT). Of course, using RESOLVE_ROUTINE, manually
compiling, doing a .reset, etc. changes everything.

My suggestion: name them TEST1_MY_PLOT and TEST2_MY_PLOT.

Mike
--
www.michaelgalloy.com
Associate Research Scientist
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: question relating to FFT
Next Topic: BYTSCL bug!?

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

Current Time: Fri Oct 10 23:47:37 PDT 2025

Total time taken to generate the page: 0.62764 seconds