[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Named Indices
- Subject: Re: Named Indices
- From: davidf(at)dfanning.com (David Fanning)
- Date: Wed, 27 Sep 2000 14:07:47 -0600
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <39D232E0.494050FD@cis.rit.edu>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:21556
Jason P. Meyers (jpm7934@cis.rit.edu) writes:
> I am brand new to IDL programming. I am using version 5.3.1 on a PC
> and started going through some examples from my Digital Image Processing
> (DIP) class as well as some from the online manuals and Dave Fanning's
> book. I got to wondering if there exists (either built-in or developed
> by someone else) a list of named indices. Such a beast would be useful
> for specifying things line styles using names instead of numbers.
>
> For example,
>
> PLOT, time, curve, LineStyle=LongDash
>
> makes more sense to me than
>
> PLOT, time, curve, LineStyle=5
>
> One idea I had was to create a structured system variable named !I (for
> indices) which then has the various indices as fields. For example:
>
> !I.Solid = 0
> !I.Dot = 1
> !I.Dash = 2
> !I.DashDot = 3
> !I.Dash3Dot = 4
> !I.LongDash = 5
>
> I couldn't find a reference to such a system variable. Furthermore, I
> don't even know if it is possible to create new system variables like
> this. Finally, if something like this can be created, I don't want to
> reinvent the wheel if it already exists.
Well, it *is* possible to do something like this, since
you can make new system variables. In fact, to do what
you want to do requires an IDL statement like this:
DefSysV, '!LS', {solid:0, dot:1, dash:2, dashdot:3, dashdotdot:4, longdash:5}, 1
I used !LS for "line style", but what name you choose is up to you.
You can put this kind of statement in, for example, an IDL
start-up file.
The principle reason this is not done more often
is that programs that rely on it:
Plot, Findgen(11), Linestyle=!LS.Dash
don't work when they are passed along to someone else.
You always forget to give them your start-up file, or
they got it, but they forget to run it, etc. So most of
us stay with the lowest common denominator code:
Plot, Findgen(11), Linestyle=2
And most of us (present company included) don't have any
idea what that code does five minutes after we write the
program.
And, anyway, making code "readable" is not really the
true programmer's solution anyway. If you want to earn
the big bucks, "cryptic" is better. :-)
If everyone in your workgroup would agree to use the same
IDL startup file, however, this would work great.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155