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

Home » Public Forums » archive » calling a function in herself
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
calling a function in herself [message #20893] Mon, 31 July 2000 00:00 Go to next message
J�rg Schliwa is currently offline  J�rg Schliwa
Messages: 12
Registered: April 2000
Junior Member
Hy to all!

I have a file with the main-procedure and some functions in it. When I'm in
the function e.g h_wahl I want to call the function h_wahl again. Is that
possible? When I compile the file, the expression h_wahl is not known in
h_wahl.

e.g.
;procedure rasterung.pro

Function H_Wahl(a,b,Steig=steig,Abstand=abstand)
If Keyword_Set(abstand) Then .....

If Keyword_Set(steig) Then Begin
...
return, H_Wahl(c,d,/abstand)
Endif
End

pro rasterung...

Any suggestions?

Thanks in advance,
J�rg Schliwa
Re: calling a function in herself [message #20955 is a reply to message #20893] Tue, 01 August 2000 00:00 Go to previous messageGo to next message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
David Fanning wrote:
>
> What has happened to your keyboard, Martin!?
> Better get the ol' WD40 out. :-)
>

errh. nothing to do with the keyboard. J'st m' f'ngrs gettin' sl'ppy
aft' loooon' day ;-)

Cheers,
Martin

--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
Re: calling a function in herself [message #20975 is a reply to message #20893] Mon, 31 July 2000 00:00 Go to previous messageGo to next message
promashkin is currently offline  promashkin
Messages: 169
Registered: December 1999
Senior Member
Will FORWARD_FUNCTION do the trick? Or, try placing the new "COMPILE_OPT
IDL2" instructuin at the beginning your code. It will enforce strict
array subscripting using only [ ... ], and anything with ( ... ) will be
considered a function.
Cheers,
Pavel

"J�rg Schliwa" wrote:
>
> Hy to all!
>
> I have a file with the main-procedure and some functions in it. When I'm in
> the function e.g h_wahl I want to call the function h_wahl again. Is that
> possible? When I compile the file, the expression h_wahl is not known in
> h_wahl.
>
> e.g.
> ;procedure rasterung.pro
>
> Function H_Wahl(a,b,Steig=steig,Abstand=abstand)
> If Keyword_Set(abstand) Then .....
>
> If Keyword_Set(steig) Then Begin
> ...
> return, H_Wahl(c,d,/abstand)
> Endif
> End
>
> pro rasterung...
>
> Any suggestions?
>
> Thanks in advance,
> J�rg Schliwa
Re: calling a function [message #32877 is a reply to message #20893] Fri, 15 November 2002 17:34 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Surendar Jeyadev (jeyadev@wrc.xerox.bounceback.com) writes:

>> No sense adding more confusion to an already confusing
>> situation. The average IDL newcomer is totally perplexed
>> about why a .RUN command doesn't run a damn thing, although
>
> Doesn't is run the main programme, if that is what comes
> after it?

Indeed it does. And I even used a main program
back in 1977 sometime.

>
>> we long-timers take it as a matter of course.
>
> Not completely illogical, is it?

Did I say "illogical"!? I meant "perverse". :-)

Cheers,

David


--
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
Re: calling a function [message #32878 is a reply to message #20893] Fri, 15 November 2002 11:49 Go to previous message
jeyadev is currently offline  jeyadev
Messages: 78
Registered: February 1995
Member
In article <MPG.183eed2dee8063c0989a22@news.frii.com>,
David Fanning <david@dfanning.com> wrote:
> James Kuyper (kuyper@saicmodis.com) writes:
>
>> IDL> .run /non-idl/path/name/glactc.pro
>
> No sense adding more confusion to an already confusing
> situation. The average IDL newcomer is totally perplexed
> about why a .RUN command doesn't run a damn thing, although

Doesn't is run the main programme, if that is what comes
after it?

> we long-timers take it as a matter of course.

Not completely illogical, is it?
--

Surendar Jeyadev jeyadev@wrc.xerox.bounceback.com

Remove 'bounceback' for email address
Re: calling a function [message #32895 is a reply to message #20893] Fri, 15 November 2002 10:53 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning (david@dfanning.com) writes:

> Please, let's ALL train ourselves to use .COMPILE when we
> want to compile something. That way we won't all look like
> idiots to the new users. :-)

Oh, my gosh! I inadvertently violated Commandment Number
3 of the Internet Posters Guild:

Commandment 3: Don't EVER use the words idiot, jerk,
numskull, etc. in an Internet communication unless
referring specifically to yourself and you alone. Those
words are loaded and will be misinterpreted by nearly
everyone who reads them, no matter how many smiley faces you
use at the end of the sentence.

My apologies to anyone and everyone. I was simply trying
to make the point that some of the things we do in IDL
don't seem to, uh, make a lot of sense to IDL newcomers.
That's all. :-)

Cheers,

David

--
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
Re: calling a function [message #32896 is a reply to message #20893] Fri, 15 November 2002 10:39 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
James Kuyper (kuyper@saicmodis.com) writes:

> IDL> .run /non-idl/path/name/glactc.pro

No sense adding more confusion to an already confusing
situation. The average IDL newcomer is totally perplexed
about why a .RUN command doesn't run a damn thing, although
we long-timers take it as a matter of course.

Please, let's ALL train ourselves to use .COMPILE when we
want to compile something. That way we won't all look like
idiots to the new users. :-)

Cheers,

David

--
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
Re: calling a function [message #32898 is a reply to message #20893] Fri, 15 November 2002 10:24 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Steve wrote:
>
> Dear all, I have a problem!
> I have a program (main.pro) written in IDL. Then, inside the main.pro
> I want to use a function that I found on Goddard library.
> The function is named glactc.pro, and the calling sequence is the
> following:
> GLACTC, ra, dec, year, gl, gb, j
> How can I call glactc.pro inside main.pro?

If it's really a function (starts with the FUNCTION keyword), then you
have to type:

result = GLACTC(my_ra, my_dec, my_year, my_gl, my_bg, my_j)

On the other hand, if it's a procedure (starts with the PROC keyword),
then you have to type:

GLACTC, my_ra, my_dec, my_year, my_gl, my_bg, my_j

You don't need the 'my_' prefixes, I'm just emphasizing that the names
don't need to match; it's also not an error if they do match.

> After that, when I compile the program, do I have to link
> glactc.pro?If yes, how can I do that?

No. All you have to do is make sure that glactc.pro is in a directory
that's in IDL's search path. That can either be in your current
directory, or in one of the directories listed in the IDL_PATH
environment variable.
Alternatively, you can load glactc.pro, even if it's not in the
IDL_PATH, by
typing:

IDL> .run /non-idl/path/name/glactc.pro

You don't need to add the '.pro' at the end; IDL will figure it out if
you leave it out.

Note: if the name of the file is different from the name of the
procedure or function that you need to execute, then you have to use the
'.run' approach. That's why it's generally a good idea to have the
function and the filename match.

> Is it possible to write "makefile" (like C programming) into IDL?

No, but the reason it's not possible is that it's not really needed.
Re: calling a function [message #32901 is a reply to message #20893] Fri, 15 November 2002 08:54 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Steve (Steve.Morris@libero.it) writes:

> I have a program (main.pro) written in IDL. Then, inside the main.pro
> I want to use a function that I found on Goddard library.
> The function is named glactc.pro, and the calling sequence is the
> following:
> GLACTC, ra, dec, year, gl, gb, j
> How can I call glactc.pro inside main.pro?

Just exactly as you did right there. That's it! :-)

> After that, when I compile the program, do I have to link
> glactc.pro?If yes, how can I do that?

You don't have to compile it. IDL will find it and compile
it when it needs it. That is, when it gets to the statement
above in your code. Just put it in a file named glactc.pro
and make sure the procedure GLACTC is the *last* program
module in the file. (This will be true for most of the routines
you get from established libraries, but may not be true for most
of the routines you get from your buddies.)

> Is it possible to write "makefile" (like C programming) into IDL?

Forget makefiles. Forget compiling. You are working with IDL now! :-)

Cheers,

David
--
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Structure Pass By Reference?
Next Topic: Problems getting CURVEFIT to work

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

Current Time: Wed Oct 08 17:11:44 PDT 2025

Total time taken to generate the page: 0.00741 seconds