Named Indices [message #21915] |
Wed, 27 September 2000 00:00  |
Jason P. Meyers
Messages: 24 Registered: September 2000
|
Junior Member |
|
|
Hello,
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.
Any and all advice is greatly welcomed.
Thanks,
Jason Meyers
Ph.D. Student, Center for Imaging Science
Rochester Institute of Technology
jpm7934@rit.edu
|
|
|
Re: Named Indices [message #21965 is a reply to message #21915] |
Mon, 02 October 2000 23:03  |
Michael Asten
Messages: 53 Registered: March 1999
|
Member |
|
|
Given that it is that simple, Im amazed that IDL havnt done it within the
factory-release, and amazed that gurus like David who specialise in making idl
better, havent adopted it as standard. Understood that there might be problems when
someone forgets the startup file, but then, how often do we see a perfect solution
from DWF along with the caveat "you will also need my routines xcolors.pro" or
similar.
Thanks for the insight David.
Regards,
Michael Asten
David Fanning wrote:
> 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
|
|
|