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

Home » Public Forums » archive » Beginer question about the @ usage
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
Beginer question about the @ usage [message #44850] Wed, 27 July 2005 10:32 Go to next message
Mathieu Malaterre is currently offline  Mathieu Malaterre
Messages: 32
Registered: July 2005
Member
Hello,

So I am slowly learning idl, and I am confused on the use of the '@' to
include files.

If I have:
::::::::::::::
hello.pro
::::::::::::::
print, 'Hello World'
exit


I can just run
$ idl hello.pro
and everything is fine

If I have then:
::::::::::::::
lib.pro
::::::::::::::
; Lib containing one Function

; carre return the square of its input
Function carre, input
return, input*input
End
::::::::::::::
testlib.pro
::::::::::::::
; include the content of file: lib.pro
@lib
a = 5
print, a
b = carre(a)
print, b
exit



I cannot run :
$ idl testlib.pro

it returns:
% Programs can't be compiled from single statement mode.

Then I tried:
$ echo testlib | idl
but then it returns:
% Attempt to call undefined procedure/function: 'TESTLIB'.
% Execution halted at: $MAIN$


What is the correct way to run testlib.pro ?

Thanks
Mathieu
Re: Beginer question about the @ usage [message #44952 is a reply to message #44850] Fri, 29 July 2005 06:26 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
edward.s.meinel@aero.org writes:

> I noticed that no one answered this question. DF, how could you let us
> down like this?
>
> Anyway, when using @ IDL expects the full filename, unlike .compile or
> .run which assume a .pro extension.

I didn't know that! :-)

And I'm not even sure it is true. You can count the times
I've used the @ sign in the last 18 years on one hand, but
I just looked at one program where I do use it and it certainly
is using a relative path name.

But mostly I didn't answer because I didn't understand
the question. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Beginer question about the @ usage [message #44954 is a reply to message #44850] Fri, 29 July 2005 06:14 Go to previous message
edward.s.meinel@aero. is currently offline  edward.s.meinel@aero.
Messages: 52
Registered: February 2005
Member
I noticed that no one answered this question. DF, how could you let us
down like this?

Anyway, when using @ IDL expects the full filename, unlike .compile or
.run which assume a .pro extension.

You'll find that IDL does a lot of really neat things, but
documentation is not one of them...

Ed

Mathieu Malaterre wrote:
>> What is the correct way to run testlib.pro ?
>
> ok I found a working example:
>
> http://groups-beta.google.com/group/comp.lang.idl-pvwave/msg /f539ce41dda7574b
>
> Still don't understand why PRO is needed...
>
> Mathieu
Re: Beginer question about the @ usage [message #44976 is a reply to message #44850] Thu, 28 July 2005 00:00 Go to previous message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
Mathieu Malaterre wrote:
> Mathieu Malaterre wrote:
>
>> BTW Paul,
>>
>> Did you on purpose use lower case for function and upper case for
>> procedure or is this only pure coincidence ? Seems like people prefer
>> the FORTRAN approach where everything is in upper case, (except the
>> filename which seems to have to be in lower case).
>
>
> How about this one ?
>
> http://groups-beta.google.com/group/comp.lang.idl-pvwave/msg /e2e07789972a7ecd?hl=en&
>

This style guide is closed to my IDL style, perhaps it will be useful
for you:
http://www.customvisuals.com/IDL_Style.html

--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
Grup de Recerca Aplicada en Hidrometeorologia (GRAHI)
Universitat Polit�cnica de Catalunya
Barcelona - SPAIN
-----------------------------------------------------
http://www.grahi.upc.edu
-----------------------------------------------------
Re: Beginer question about the @ usage [message #44979 is a reply to message #44850] Wed, 27 July 2005 15:16 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> I don't follow a lot of Michael Wallace's suggestions

Neither do the guys I work with. ;-)


> but that's not at all a value judgement on his conventions.
> The thing I think is key is consistency. Whether you prefer lower or
> upper case for IDL reserved words, pick one and stick to it. There is
> nothing that, to me, suggests lack of care as when I see people mix
> conventions in code. Just because we sit in front of computers for a
> living doesn't mean we can't be craftsmen (craftspeeples?) and make our
> code creations look good.

I agree completely. More important than the coding convention you
choose is that you remain consistent with whatever you choose. There is
no default style guide for IDL and RSI even uses inconsistent styles
within their own code, so that can't be used as a style basis either.
I'd recommend looking at RSI's coding style and the style used by those
here in the newsgroup. You'll find that there are certain styles you
like and certain ones you don't. It will take a while, but over time
you'll know how to write things so that you can read them easily. That
doesn't mean that any of the rest of us will think it is easy, however. ;-)

-Mike
Re: Beginer question about the @ usage [message #44981 is a reply to message #44850] Wed, 27 July 2005 14:25 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Mathieu Malaterre wrote:
> Mathieu Malaterre wrote:
>
>> BTW Paul,
>>
>> Did you on purpose use lower case for function and upper case for
>> procedure or is this only pure coincidence ? Seems like people prefer
>> the FORTRAN approach where everything is in upper case, (except the
>> filename which seems to have to be in lower case).
>
>
> How about this one ?
>
> http://groups-beta.google.com/group/comp.lang.idl-pvwave/msg /e2e07789972a7ecd?hl=en&

Whatever floats your boat. I don't follow a lot of Michael Wallace's suggestions, but that's not at
all a value judgement on his conventions. The thing I think is key is consistency. Whether you
prefer lower or upper case for IDL reserved words, pick one and stick to it. There is nothing that,
to me, suggests lack of care as when I see people mix conventions in code. Just because we sit in
front of computers for a living doesn't mean we can't be craftsmen (craftspeeples?) and make our
code creations look good.

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Re: Beginer question about the @ usage [message #44982 is a reply to message #44850] Wed, 27 July 2005 14:13 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Mathieu Malaterre wrote:
> BTW Paul,
>
> Did you on purpose use lower case for function and upper case for
> procedure or is this only pure coincidence ? Seems like people prefer
> the FORTRAN approach where everything is in upper case, (except the
> filename which seems to have to be in lower case).

Coming from the unix world where there is filename case sensitivity, the filenames should be all
lowercase. The name of the function or procedure in the file can be whatever you prefer.

My personal preference (that I also use in my Fortran95 code) is that IDL
statements/keywords/procedures/functions/etc are in all upper case. My own routines are usually
combos of upper and lower with underscores tossed in, but never all upper. Examples I type in to
this newsgroup don't necessarily count :o)

My recommendation is to type stuff in such a way as to make the code as readable and understandable
as possible -- to you and others. How you achieve that (via case, indenting, naming conventions,
comments etc) is up to you and subject to your own personal tastes (IMO). As long as you're
consistent and your code is understandable[1], don't listen to anyone that tells you you must do
something a particular way[2]

paulv

[1] If a typical non-IDL knowledgable 12-15 year old can understand your code, you're doing all
right. If no adolescents are available, any colleague will probably do. :o)

[2] Something I suffer from, unfortunately. It drives me nuts when people give me code that isn't
lined up "correctly"! :oD


--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Re: Beginer question about the @ usage [message #44983 is a reply to message #44850] Wed, 27 July 2005 14:02 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mathieu Malaterre writes:

> Since you actually typed the url with a typo I understood you knew them
> all by heart (==there full path on the web server)...

Oh, I see. Well, I don't usually access the page over
the Internet. I use my local copy since it is faster.
Thus, I have to type the first part of the URL and copy
the last part. You would think I would know my own web
page address, but alas I post so infrequently these days
even that is disappearing from my short-term memory. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Beginer question about the @ usage [message #44984 is a reply to message #44850] Wed, 27 July 2005 13:57 Go to previous message
Mathieu Malaterre is currently offline  Mathieu Malaterre
Messages: 32
Registered: July 2005
Member
Mathieu Malaterre wrote:
> BTW Paul,
>
> Did you on purpose use lower case for function and upper case for
> procedure or is this only pure coincidence ? Seems like people prefer
> the FORTRAN approach where everything is in upper case, (except the
> filename which seems to have to be in lower case).

How about this one ?

http://groups-beta.google.com/group/comp.lang.idl-pvwave/msg /e2e07789972a7ecd?hl=en&
Re: Beginer question about the @ usage [message #44985 is a reply to message #44850] Wed, 27 July 2005 13:58 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Mathieu Malaterre wrote:

> I was sort of surprised that @ was not really documented,

Well, as an IDL beginner, you better get used to that. :o) You'll find there quite a bit of handy
stuff in IDL that is documented/cross-referenced in an, umm, interesting manner. The "@" is a good
example actually. Its function _is_ documented (Appendix F of the online help), but unless you know
to look for the "@" in the first place, you're pretty much stuck (i.e. the index does not have a
link under the word "include files".... but it does under "batch files". Go figure).

I just grabbed my copy of Liam's IDL book from my shelf and, sure enough, in the index there is an
entry under "include files". It's worth your while to check his book out from the library or get
your own copy if you're going to be using IDL for anything useful (see www.gumley.com)

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Re: Beginer question about the @ usage [message #44986 is a reply to message #44850] Wed, 27 July 2005 13:56 Go to previous message
Mathieu Malaterre is currently offline  Mathieu Malaterre
Messages: 32
Registered: July 2005
Member
David Fanning wrote:
> Mathieu Malaterre writes:
>
>
>> Thanks. Do you actually know by heart all your tips and there full path
>> ? :)
>
>
> Are you kidding!? If I could remember this stuff I sure as
> hell wouldn't be spending all the time it takes to write
> it down. :-)

Since you actually typed the url with a typo I understood you knew them
all by heart (==there full path on the web server)...

2 cents,
Mathieu
Re: Beginer question about the @ usage [message #44988 is a reply to message #44850] Wed, 27 July 2005 13:54 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mathieu Malaterre writes:

> Thanks. Do you actually know by heart all your tips and there full path
> ? :)

Are you kidding!? If I could remember this stuff I sure as
hell wouldn't be spending all the time it takes to write
it down. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Beginer question about the @ usage [message #44989 is a reply to message #44850] Wed, 27 July 2005 13:49 Go to previous message
Mathieu Malaterre is currently offline  Mathieu Malaterre
Messages: 32
Registered: July 2005
Member
BTW Paul,

Did you on purpose use lower case for function and upper case for
procedure or is this only pure coincidence ? Seems like people prefer
the FORTRAN approach where everything is in upper case, (except the
filename which seems to have to be in lower case).

Comments welcome
Mathieu
Re: Beginer question about the @ usage [message #44990 is a reply to message #44850] Wed, 27 July 2005 13:46 Go to previous message
Mathieu Malaterre is currently offline  Mathieu Malaterre
Messages: 32
Registered: July 2005
Member
> http://www.fanning.com/tips/namefiles.html
^ 404

Thanks. Do you actually know by heart all your tips and there full path
? :)

Matheiu
Re: Beginer question about the @ usage [message #44991 is a reply to message #44850] Wed, 27 July 2005 13:41 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
David Fanning wrote:
> Paul is certainly correct, but I do wish he had named
> that event handler MYWIDGET_EXIT_EVENT. Giving
> arbitrary names to utility routines (for, in fact,
> this is what any module in the file *before* the main
> or command module is) will lead you, eventually, to
> spending a long week trying to figure out why your
> code works perfectly sometimes and not at all other
> times. :-)

Yes, you're right. But dealing with two subjects (compilation stuff and namespace pollution) in the
same post is more than I can handle right now. The excessive heat is trickling through the plate
glass in spite of the AC and I'm sleepy... :o)

But, rest assured, the widgetapp I culled the example from follows your advice. Everything of any
consequence is prefixed with "SurfaceFWDTLMtest_". I guess this could also be thought of as a form
of namespace pollution depending on one's level of verbosity (mine is quite high :o)

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Re: Beginer question about the @ usage [message #44992 is a reply to message #44850] Wed, 27 July 2005 13:17 Go to previous message
Mathieu Malaterre is currently offline  Mathieu Malaterre
Messages: 32
Registered: July 2005
Member
<snip>
>
> Note that the MAIN routine, mywidget, is AFTER the event handler. This
> ensures that the dependent "Exit_Event" routine is compiled whenever the
> "mywidget" procedure is invoked. If you put the event handler after the
> main routine, it would not get compiled.

Paul,

Thank you ! This is extremely usefull.
I was sort of surprised that @ was not really documented, and since the
Windows interface does not allow <right click+goto file> on the '@' I
was wondering if anybody was really using it.

Thanks again,
Mathieu
Re: Beginer question about the @ usage [message #44993 is a reply to message #44850] Wed, 27 July 2005 13:09 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paul Van Delst writes:

> The usual exception to the each-function-in-its-own-file rule is things like widget code where event
> handlers are placed in the same file as the widget creation code, e.g. mywidget.pro contains:
>
> PRO Exit_Event, Event
> WIDGET_CONTROL, Event.Top, /DESTROY
> END
>
> PRO mywidget
> Top_Level_Base_ID = WIDGET_BASE( COLUMN = 1, $
> MAP = Map, $
> MBAR = Menu_Bar_ID, $
> TITLE = 'MyWidget' )
> File_Menu_ID = WIDGET_BUTTON( Menu_Bar_ID, $
> VALUE = 'File', $
> /MENU )
> File_Exit_ID = WIDGET_BUTTON( File_Menu_ID, $
> VALUE = 'Exit', $
> EVENT_PRO = 'Exit_Event', $
> /SEPARATOR, $
> UVALUE = 'Exit' )
> WIDGET_CONTROL, Top_Level_Base_ID, MAP = Map, $
> REALIZE = 1, $
> UPDATE = 1
> XMANAGER, 'mywidget', Top_Level_Base_ID
>
> END
>
>
> Note that the MAIN routine, mywidget, is AFTER the event handler. This ensures that the dependent
> "Exit_Event" routine is compiled whenever the "mywidget" procedure is invoked. If you put the event
> handler after the main routine, it would not get compiled.

Paul is certainly correct, but I do wish he had named
that event handler MYWIDGET_EXIT_EVENT. Giving
arbitrary names to utility routines (for, in fact,
this is what any module in the file *before* the main
or command module is) will lead you, eventually, to
spending a long week trying to figure out why your
code works perfectly sometimes and not at all other
times. :-)

Here is an article if you are interested in learning
more:

http://www.fanning.com/tips/namefiles.html

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Beginer question about the @ usage [message #44994 is a reply to message #44850] Wed, 27 July 2005 12:50 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Mathieu Malaterre wrote:
>
>> What is the correct way to run testlib.pro ?
>
>
> ok I found a working example:
>
> http://groups-beta.google.com/group/comp.lang.idl-pvwave/msg /f539ce41dda7574b
>
>
> Still don't understand why PRO is needed...

The usual recommendation is to put any procedure/function that you will ever want to call in a file
with the same name as the function.

e.g. bananas.pro contains

pro BaNaNaS, input, output
output = input * 2
end

and applesandoranges.pro contains

function AppleSandOrangeS, input
return, input^2
end

(note the filenames are all lower case, whereas the routine names can be upper, lower, or mixture)

When IDL searches for a routine (if it hasn't already been compiled) it looks for a file with the
same name as the routine name.

If you do this, there is limited utility to using the @ functionality to stick code in other files
(exceptions, of course, exist). I use the @ include stuff for files containing just numbers that I
treat as unmodifiable parameters (i.e. parameters in the Fortran sense, not the IDL argument sense)

The usual exception to the each-function-in-its-own-file rule is things like widget code where event
handlers are placed in the same file as the widget creation code, e.g. mywidget.pro contains:

PRO Exit_Event, Event
WIDGET_CONTROL, Event.Top, /DESTROY
END

PRO mywidget
Top_Level_Base_ID = WIDGET_BASE( COLUMN = 1, $
MAP = Map, $
MBAR = Menu_Bar_ID, $
TITLE = 'MyWidget' )
File_Menu_ID = WIDGET_BUTTON( Menu_Bar_ID, $
VALUE = 'File', $
/MENU )
File_Exit_ID = WIDGET_BUTTON( File_Menu_ID, $
VALUE = 'Exit', $
EVENT_PRO = 'Exit_Event', $
/SEPARATOR, $
UVALUE = 'Exit' )
WIDGET_CONTROL, Top_Level_Base_ID, MAP = Map, $
REALIZE = 1, $
UPDATE = 1
XMANAGER, 'mywidget', Top_Level_Base_ID

END


Note that the MAIN routine, mywidget, is AFTER the event handler. This ensures that the dependent
"Exit_Event" routine is compiled whenever the "mywidget" procedure is invoked. If you put the event
handler after the main routine, it would not get compiled.

paulv
--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Re: Beginer question about the @ usage [message #44996 is a reply to message #44850] Wed, 27 July 2005 12:10 Go to previous message
Mathieu Malaterre is currently offline  Mathieu Malaterre
Messages: 32
Registered: July 2005
Member
> What is the correct way to run testlib.pro ?

ok I found a working example:

http://groups-beta.google.com/group/comp.lang.idl-pvwave/msg /f539ce41dda7574b

Still don't understand why PRO is needed...

Mathieu
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Multithreading in IDL
Next Topic: Re: () and execution speed

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

Current Time: Wed Oct 08 15:06:34 PDT 2025

Total time taken to generate the page: 0.00756 seconds