Re: Is there any conventions style programming IDL? [message #39103 is a reply to message #39101] |
Thu, 22 April 2004 07:24   |
meinel
Messages: 14 Registered: February 1994
|
Junior Member |
|
|
"Esteban Garc�a Cuesta" <egc@fis.uc3m.es> wrote in message news:<c686up$a84$1@khitai.uc3m.es>...
> Hello,
> I'm trying to standarize the way we programm in IDL , is there any
> rules or conventions programming IDL ?
>
> Thanks a lot.
> Esteban Garc�a Cuesta
Only personal preferences. If you use EMACS there is a plug-in that
will take care of most pretty-fying for you.
My personal preferences for ease of readability are:
Procedures/functions/keywords all UPPERCASE
Variables all lowercase
Indent FOR loops, CASE, IF, continuation lines
Keywords on separate continuation lines
Align multiple "=" or "$" or anything else common to multiple lines
A keyword and its associated variable should have the same name
For example, call a procedure with multiple keywords:
---------------------------------------------
PLOT, hist, $
XMARGIN = [0, 0], $
YMARGIN = [0, 0], $
XSTYLE = 1, $
PSYM = 10, $
YRANGE = [0, 0.9*MAX(hist)] , $
XRANGE = [0, N_ELEMENTS(hist) - 1]
---------------------------------------------
(I don't know how this will appear on GOOGLE, but if you use a
fixed-pitch font, these lines will appear the way I described)
Multiple IF...THEN lines:
---------------------------------------------
; Defaults for keywords
IF (N_ELEMENTS(title) EQ 0) THEN title = 'New Data'
IF (N_ELEMENTS(latitude) EQ 0) THEN latitude = [0, 0, 0, 0]
IF (N_ELEMENTS(longitude) EQ 0) THEN longitude = [0, 0, 0, 0]
IF (N_ELEMENTS(filename) EQ 0) THEN filename = ''
IF (N_ELEMENTS(true) EQ 0) THEN true = 3
---------------------------------------------
Of course, if you are devious and WANT to make your distribution code
hard to read, you can remove all extra white space (all UPPERCASE
strings need whitespace) and reassign the variables with random
strings (search for lowercase strings).
Have fun!
Ed Meinel
|
|
|